Podman : Access to Services on Containers2025/11/12 |
|
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 [httpd] is installed. |
|
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/fedora-httpd latest 9681aa9061c7 About a minute ago 349 MB registry.fedoraproject.org/fedora latest a9005aba99b1 2 days ago 186 MB # run a 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 5bc20f9e40dfe4f8fa7e20c6c89c9ef93bff4398db1f8fcbc1713f2910c8af84[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5bc20f9e40df srv.world/fedora-httpd:latest /usr/sbin/httpd -... 14 seconds ago Up 15 seconds 0.0.0.0:8081->80/tcp unruffled_nightingale # create a test page [root@dlp ~]# podman exec 5bc20f9e40df /bin/bash -c 'echo "httpd on Podman Container" > /var/www/html/index.html'
# verify 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",
"IPAddress": "10.88.0.7",
[root@dlp ~]# curl 10.88.0.7 httpd on Podman Container |
| Sponsored Link |
|
|