Fedora 42
Sponsored Link

Podman : Access to Services on Containers2025/04/25

 

If you'd like to access to services like HTTP or SSH that are running on Containers as daemons, Configure like follows.

[1] For example, use a Container that [httpd] is installed.
[root@dlp ~]#
podman images

REPOSITORY                         TAG         IMAGE ID      CREATED        SIZE
srv.world/fedora-httpd             latest      512d39041a55  4 minutes ago  328 MB
registry.fedoraproject.org/fedora  latest      e5bf03515e92  22 hours ago   166 MB

# run a container and also start [httpd]
# map with [-p xxx:xxx] to [(Host Port):(Container Port)]

[root@dlp ~]#
podman run -dt -p 8081:80 srv.world/fedora-httpd /usr/sbin/httpd -D FOREGROUND

32b2aba267a9ab4be6daa8d4efc027b1d1b7b11fc90b4b5bf505ad41e6f7d08f

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED         STATUS         PORTS                 NAMES
32b2aba267a9  srv.world/fedora-httpd:latest  /usr/sbin/httpd -...  15 seconds ago  Up 15 seconds  0.0.0.0:8081->80/tcp  strange_carson

# create a test page

[root@dlp ~]#
podman exec 32b2aba267a9 /bin/bash -c 'echo "httpd on Podman Container" > /var/www/html/index.html'
# verify accesses

[root@dlp ~]#
curl localhost:8081

httpd on Podman Container
# also possible to access via container network

[root@dlp ~]#
podman inspect -l | grep \"IPAddress

               "IPAddress": "10.88.0.7",
                         "IPAddress": "10.88.0.3",

[root@dlp ~]#
curl 10.88.0.3

httpd on Podman Container
Matched Content