Podman : Access to Services on Containers2021/07/29 |
If you'd like to access to services like HTTP or SSH that are running on Containers as daemons, Configure like follows.
|
|
[1] | For exmaple, use a Container that [httpd] is installed. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/rocky-httpd latest bb62279be7bd 2 minutes ago 342 MB docker.io/rockylinux/rockylinux latest 333da17614b6 5 weeks ago 234 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/rocky-httpd /usr/sbin/apachectl -D FOREGROUND c44312ba6132c542e890eaf93776ba22953fe5086bcb75438e66f632db055fac[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c44312ba6132 srv.world/rocky-httpd /usr/sbin/apachec... 7 seconds ago Up 7 seconds ago 0.0.0.0:8081->80/tcp silly_goldberg # create a test page [root@dlp ~]# podman exec c44312ba6132 /bin/bash -c 'echo "httpd on Podman Container" > /var/www/html/index.html'
# verisy 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 |