Ubuntu 16.04
Sponsored Link

Docker : Access to Containers2016/06/17

 
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 Apache 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/ubuntu_httpd /bin/bash
# start Apache2 and exit the Container

root@cf8b91524639:/#
echo "ServerName www.srv.world" >> /etc/apache2/apache2.conf

root@cf8b91524639:/#
echo "Apache2 on Docker Container" > /var/www/html/index.html

root@cf8b91524639:/#
/etc/init.d/apache2 start

* Starting Apache httpd web server apache2 *
root@cf8b91524639:/#    
# Ctrl+p, Ctrl+q key
root@dlp:~#
docker ps

CONTAINER ID    IMAGE                   COMMAND       CREATED          STATUS           PORTS                  NAMES
cf8b91524639    my_image/ubuntu_httpd   "/bin/bash"   3 minutes ago    Up 3 minutes     0.0.0.0:8081->80/tcp   modest_leavitt

# verify working

root@dlp:~#
curl http://127.0.0.1:8081/

Apache2 on Docker Container    
# just accessed
Matched Content