Tuesday, November 25, 2025

Podman : Access to Services on Containers

 

Podman : Access to Services on Containers


 

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/debian-apache2  latest      a0aca892bf29  3 minutes ago  234 MB
docker.io/library/debian  latest      047bd8d81940  11 days ago    124 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

0597fca3c1d81f8a8970d30a4ed85b853e4a085666532697aa775a9c07b8aa8d

root@dlp:~# 
podman ps

CONTAINER ID  IMAGE                            COMMAND               CREATED        STATUS         PORTS                 NAMES
0597fca3c1d8  srv.world/debian-apache2:latest  /usr/sbin/apachec...  9 seconds ago  Up 10 seconds  0.0.0.0:8081->80/tcp  competent_merkle

# create a test page

root@dlp:~# 
podman exec 0597fca3c1d8 /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.11",
                         "IPAddress": "10.88.0.11",

root@dlp:~# 
curl 10.88.0.11

Apache2 on Podman Container

No comments:

Post a Comment