Podman : Access to Services on Containers2025/04/22 |
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 b7f1351d1b3c About a minute ago 246 MB docker.io/library/ubuntu latest 602eb6fb314b 13 days ago 80.6 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/ubuntu-apache2 /usr/sbin/apachectl -D FOREGROUND 0078a1dcbeec8d7f6822d0fead672bac622d3fb5d2a4bac836736c34d513ced7root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0078a1dcbeec srv.world/ubuntu-apache2:latest /usr/sbin/apachec... 12 seconds ago Up 13 seconds 0.0.0.0:8081->80/tcp naughty_austin # create a test page root@dlp:~# podman exec 0078a1dcbeec /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 |
Sponsored Link |