Podman : Access to Services on Containers2024/11/06 |
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 4dfbd95b4ef6 2 minutes ago 319 MB registry.fedoraproject.org/fedora latest 99519fcf3c1b 17 hours ago 163 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 efb4493f7153384b7c73928cb3c7d7fb744c9dbd18ad5b0c1810bd6d4683acda[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES efb4493f7153 srv.world/fedora-httpd:latest /usr/sbin/httpd -... 16 seconds ago Up 16 seconds 0.0.0.0:8081->80/tcp zen_dubinsky # create a test page [root@dlp ~]# podman exec efb4493f7153 /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 |