CentOS 7
Sponsored Link

Docker : Access to Container Services2015/01/10

 
If you'd like to access to services like HTTP or SSH which is running in Containers as a daemon, Configure like follows.
[1] For example, Use a Container image which has Nginx.
# start a Container and also run Nginx

# 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/centos-nginx /usr/sbin/nginx -g "daemon off;"

a8e3bfc7253f4761eb1737c134b79e139cb6e278aa9744a06f5ccb85e1216995

[root@dlp ~]#
docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS         PORTS                                   NAMES
a8e3bfc7253f   srv.world/centos-nginx   "/usr/sbin/nginx -g …"   10 seconds ago   Up 8 seconds   0.0.0.0:8081->80/tcp, :::8081->80/tcp   heuristic_margulis

# create a test page

[root@dlp ~]#
docker exec a8e3bfc7253f /bin/bash -c 'echo "Nginx on Docker Container" > /usr/share/nginx/html/index.html'
# verify it works normally

[root@dlp ~]#
curl localhost:8081

Nginx on Docker Container
Matched Content