Docker : Access to the Container2015/01/20 |
If you'd like to access to services like HTTP or SSH which is running in Containers as a daemon, set like follows.
|
|
[1] | For exmaple, use a Container which has httpd. |
# start the Container and connect to the shell session # map the port of Host and the port of Container with "-p xxx:xxx" [root@dlp ~]# docker run -it -p 8081:80 custom/centos_httpd /bin/bash
# start httpd and exit the Container [root@0097b1a3c1e4 /]# /usr/sbin/httpd & [root@0097b1a3c1e4 /]# echo "httpd on Docker Container" > /var/www/html/index.html [root@0097b1a3c1e4 /]# # Ctrl+p, Ctrl+q key docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 0097b1a3c1e4 custom/centos_httpd:latest "/bin/bash" 58 seconds ago Up 56 seconds 0.0.0.0:8081->80/tcp |
[2] | Access to the URL via HTTP from a client which is in the same LAN with Container and make sure it's possible to access normally. |
Sponsored Link |