Podman : Access to Services on Containers2021/03/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 [httpd] is installed. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/centos-httpd latest 6a4b6e2cae37 9 minutes ago 322 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 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/centos-httpd /usr/sbin/apachectl -D FOREGROUND e2acae2d06f1d29363a0caa078d355374a15056b517b0885acfbd46b7152b396[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e2acae2d06f1 srv.world/centos-httpd /usr/sbin/apachec... 9 seconds ago Up 10 seconds ago 0.0.0.0:8081->80/tcp elastic_galileo # create a test page [root@dlp ~]# podman exec e2acae2d06f1 /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.16", "IPAddress": "10.88.0.16",[root@dlp ~]# curl 10.88.0.16 httpd on Podman Container |
Sponsored Link |