Fedora 34
Sponsored Link

Podman : Access to Services on Containers
2021/05/14
 
If you'd like to access to services like HTTP or SSH that are running on Containers as daemons, Configure like follows.
[1] For exmaple, use a Container that [httpd] is installed.
[root@dlp ~]#
podman images

REPOSITORY                         TAG     IMAGE ID      CREATED             SIZE
srv.world/fedora-httpd             latest  810bed9d1157  About a minute ago  529 MB
registry.fedoraproject.org/fedora  latest  5f05951e2065  2 weeks ago         187 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

8719563c0cd650179b3156297174905caddede90263da32e83b599932d876467

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED         STATUS             PORTS                 NAMES
8719563c0cd6  srv.world/fedora-httpd:latest  /usr/sbin/httpd -...  13 seconds ago  Up 14 seconds ago  0.0.0.0:8081->80/tcp  nice_yalow

# create a test page

[root@dlp ~]#
podman exec 8719563c0cd6 /bin/bash -c 'echo "httpd on Podman Container" > /var/www/html/index.html'
# verisy 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.10",
                    "IPAddress": "10.88.0.10",

[root@dlp ~]#
curl 10.88.0.10

httpd on Podman Container
Matched Content