Debian 11 Bullseye
Sponsored Link

Podman : Access to Services on Containers2021/08/28

 
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 [apache2] is installed.
root@dlp:~#
podman images

REPOSITORY                TAG     IMAGE ID      CREATED             SIZE
srv.world/debian-apache2  latest  68a7269c5457  About a minute ago  260 MB
docker.io/library/debian  latest  fe3c5de03486  10 days ago         129 MB

# run a container and also start [apache2]

# map with [-p xxx:xxx] to [(Host Port):(Container Port)]

root@dlp:~#
podman run -dt -p 8081:80 srv.world/debian-apache2 /usr/sbin/apachectl -D FOREGROUND

6c1213aa79ab15885b35d49563be6c450e9a42ed75b49a4ec45c2d197ab4960e

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                     COMMAND               CREATED         STATUS             PORTS                 NAMES
6c1213aa79ab  srv.world/debian-apache2  /usr/sbin/apachec...  10 seconds ago  Up 11 seconds ago  0.0.0.0:8081->80/tcp  hopeful_dubinsky

# create a test page

root@dlp:~#
podman exec 6c1213aa79ab /bin/bash -c 'echo "Apache2 on Podman Container" > /var/www/html/index.html'
# verisy accesses

root@dlp:~#
curl localhost:8081

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

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

            "IPAddress": "172.16.16.7",
                    "IPAddress": "172.16.16.7",

root@dlp:~#
curl 172.16.16.7

Apache2 on Podman Container
Matched Content