Fedora 33
Sponsored Link

Podman : Access to Services on Container2020/11/06

 
If you'd like to access to services like HTTP or SSH that is running on Containers as a daemon, 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  56430ecb044d  2 minutes ago  439 MB
registry.fedoraproject.org/fedora  latest  79fd58dc7611  8 days ago     181 MB

# run 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

bed032a21a6ca469efec41d02e1bf92645353bd770af5b4874e6fd66f63b5b1b

[root@dlp ~]#
podman ps

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

# create a test page

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

[root@dlp ~]#
curl 10.88.0.7

httpd on Podman Container
Matched Content