Docker : Access to Services on Container2019/05/10 |
If you'd like to access to services like HTTP or SSH which is running on Containers as a daemon, set like follows.
|
|
[1] | For exmaple, use a Container which has httpd. |
# start the Container and also run httpd # map the port of Host and the port of Container with [-p xxx:xxx] [root@dlp ~]# docker run -t -d -p 8081:80 srv.world/fedora_httpd /usr/sbin/httpd -D FOREGROUND
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4118127bae7b srv.world/fedora_httpd "/usr/sbin/httpd -..." 7 seconds ago Up 5 seconds 0.0.0.0:8081->80/tcp eager_ramanujan # create a test page [root@dlp ~]# docker exec 4118127bae7b /bin/bash -c 'echo "httpd on Docker Container" > /var/www/html/index.html'
# verify it works normally [root@dlp ~]# curl localhost:8081 httpd on Docker Container |
Sponsored Link |