Replies: 5 comments
-
|
That is by design, exposing services on localhost by default to all container could be a security issue. As such this name should not resolve to such address. If you want to do this you can use Both options can be set ion compose files, the |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for your fast reply and explanation. Maybe you can move this from issues into discussions then? I tested your suggested solution like this: # in one session create a simple webserver
echo "something" > index.html
python3 -m http.server -b 127.0.0.1
# in another session
podman run --rm --network=pasta:--map-host-loopback,169.254.1.3 --add-host host.containers.internal:169.254.1.3 -it alpine/curl curl host.containers.internal:8000This worked perfectly well. Then I created a compose file like this: services:
alp:
image: alpine/curl
command: sleep infinity
extra_hosts:
- "host.containers.internal:169.254.1.3"
network_mode: "pasta:--map-host-loopback,169.254.1.3"and ran it with Connecting this compose file with my existing shared network to service B and C however does not work. services:
alp:
image: alpine/curl
command: sleep infinity
extra_hosts:
- "host.containers.internal:169.254.1.3"
network_mode: "pasta:--map-host-loopback,169.254.1.3"
networks:
- shared
networks:
shared:
external: trueStarting with Is also tried a compose file like this: services:
alp:
image: alpine/curl
command: sleep infinity
extra_hosts:
- "host.containers.internal:169.254.1.3"
networks:
- loop
- shared
networks:
loop:
network_mode: "pasta:--map-host-loopback,169.254.1.3"
shared:
external: trueThe How could I create a loop network that maps the host loopback, or map the host loopback in my external shared network? Thank you in advance |
Beta Was this translation helpful? Give feedback.
-
|
After some more searching I was still not able to resolve this problem. services:
alp:
...
extra_hosts:
- "host.containers.loopback:host-loopback"Similar to how I am able to map the host gateway: services:
alp:
...
extra_hosts:
- "host:host-gateway"I've also thought about creating an additional interface on my host to which service A is bound, but I have not been able to find a way to make this interface visible in the compose file. |
Beta Was this translation helpful? Give feedback.
-
|
Finally I have partial success. Setup: # in one session create a simple webserver
echo "something" > index.html
python3 -m http.server -b 127.0.0.1
# in another session
# edit or create the file ~/.config/containers/containers.conf with the following content
[network]
default_rootless_network_cmd = "pasta"
pasta_options = ["--map-host-loopback", "169.254.1.3"]
# Now create the shared network as normal
podman network create shared
# create compose.yml with following contents:
services:
alp:
image: alpine/curl
command: sleep infinity
extra_hosts:
- "host.containers.internal:169.254.1.3"
networks:
- shared
networks:
shared:
external: trueStart the service with Why is this solution not optimal? |
Beta Was this translation helpful? Give feedback.
-
|
If you use custom networks then there is exactly one pasta process involved, see #22943 (comment) So either it has that option or not. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Description
I have a service "A" running on 127.0.0.1:8000 and services "B" and "C" based on compose files that need to access service A.
Services B and C share a network created with
podman network create sharedand can communicate with each other.Using host.containers.internal:8000 services B and C cannot connect to service A.
If I instead bind service A to 0.0.0.0:8000, then service B and C are able to connect to host.containers.internal:8000.
This is not a permanent option, since now service A is exposed on all interfaces.
Steps to reproduce the issue
Working example but service A is exposed:
Failing example, but that I would expect to work
Working example with service A bound to 127.0.0.1:8000 but not compatible with compose files:
Describe the results you received
The first working example exposes the service on all interfaces, which is unwanted.
The second working example would be an acceptable workaround but I have to manually retrieve the gateway address on every system. And after many hours of searching I was unable to find a way to set "map-gw" for the shared network or somewhere in the compose files.
Describe the results you expected
My expectation was that I can bind a service to 127.0.0.1 and access it within a podman container using host.containers.internal, or as a workaround that I can set map-gw for the shared network either using podman network cli or in the compose files.
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
The Ubuntu 24.04 system was running in VirtualBox.
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions