podman-py icon indicating copy to clipboard operation
podman-py copied to clipboard

Add tcp-ns option for pasta network driver

Open aparcar opened this issue 1 year ago • 3 comments

Hi, I tried all combinations I could think of but could not figure out how to create a TCP namespace forwarding of a host port to the container. Specifically I want to add 3128 from the host to the container and with the following lines in containers.conf I got it working just fine:

[network]
pasta_options = ["-T", "3128:3128"]

However, I don't want to add this to all containers, so I tried things with podman-py to no success! The closest suggestion is available at https://github.com/containers/podman-py/issues/248#issuecomment-1463728689 however my attempts resulting in some permission errors which I did not debug further (since using containers.conf just worked).

instance = podman_client.containers.create(
    ...
    networks={"pasta": {}},
    network_options={"pasta": ["tcp-ns=3128:3128"]},
    ...
)

More Ideas were things like network_options={"pasta": ["T=3128:3128"]} or even network_options={"pasta": ["T", "3128:3128"]}.

What is the right way?

aparcar avatar Sep 27 '24 16:09 aparcar

As far as I understand #439 shows how to solve this now, correct...?

sbrivio-rh avatar Nov 12 '24 12:11 sbrivio-rh

As far as I understand https://github.com/containers/podman-py/pull/439 shows how to solve this now, correct...?

There are a few comments that need to be addressed first, I pinged the reporter again

inknos avatar Nov 12 '24 14:11 inknos

I have never used podman-py but the json format should be {"pasta": ["--tcp-ns","3128:3128"]} or {"pasta": ["-T","3128:3128"]} The pasta code literally just uses the pasta(1) argument and passes them them 1 to 1 to pasta (exception being --map-gw)

Luap99 avatar Dec 13 '24 15:12 Luap99