Ubuntu 24.04
Sponsored Link

Podman : Access to Services on Containers2024/05/05

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

REPOSITORY                TAG         IMAGE ID      CREATED             SIZE
srv.world/ubuntu-apache2  latest      38d508336863  About a minute ago  226 MB
docker.io/library/ubuntu  latest      bf3dc08bfed0  5 days ago          78.7 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 --security-opt apparmor=unconfined srv.world/ubuntu-apache2 /usr/sbin/apachectl -D FOREGROUND

77c61575ad7b23c0091e0744cf691d8fb28484bd52a3be00280456e64309b191

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                            COMMAND               CREATED         STATUS         PORTS                 NAMES
77c61575ad7b  srv.world/ubuntu-apache2:latest  /usr/sbin/apachec...  14 seconds ago  Up 14 seconds  0.0.0.0:8081->80/tcp  affectionate_mirzakhani

# create a test page

root@dlp:~#
podman exec 77c61575ad7b /bin/bash -c 'echo "Apache2 on Podman Container" > /var/www/html/index.html'
# verify 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": "10.88.0.7",
                    "IPAddress": "10.88.0.7",

root@dlp:~#
curl 10.88.0.7

Apache2 on Podman Container
Matched Content