Fedora 35
Sponsored Link

Podman : Access to Services on Containers2021/11/11

 
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      3b282c5eda58  About a minute ago  418 MB
registry.fedoraproject.org/fedora  latest      1b52edb08181  7 days ago          159 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

e04c3e7dd2343ff0777774961b1304e0ddbf9b6da8eef84e80a46d464d31cedb

[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED        STATUS            PORTS                 NAMES
e04c3e7dd234  srv.world/fedora-httpd:latest  /usr/sbin/httpd -...  8 seconds ago  Up 8 seconds ago  0.0.0.0:8081->80/tcp  optimistic_bardeen

# create a test page

[root@dlp ~]#
podman exec e04c3e7dd234 /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.7",

[root@dlp ~]#
curl 10.88.0.7

httpd on Podman Container
Matched Content