Fedora 21
Sponsored Link

Docker : Access to the containers2015/01/03

 
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 my_image/fedora_httpd /bin/bash
# start httpd & create a test page and exit from the Container

bash-4.3#
/usr/sbin/httpd &

bash-4.3#
echo "httpd on Docker Container" > /var/www/html/index.html

root@dae3e99c727d:/#
# Ctrl+p, Ctrl+q key
[root@dlp ~]#
docker ps

CONTAINER ID IMAGE                        COMMAND     CREATED       STATUS        PORTS                  
189ec889fd6e my_image/fedora_httpd:latest "/bin/bash" 5 minutes ago Up 4 minutes  0.0.0.0:8081->80/tcp
[2] Access to the test page with HTTP from a computer which is in the same network with container and make sure it is normally shown.
Matched Content