Debian 9 Stretch
Sponsored Link

Docker : Access to Services on Container2017/08/03

 
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 apache2.
# start the Container

# 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/deb_apache2 /bin/bash

1ce587828924ec59addae34ba2ac9d49c20d992b0db9a947b525849f2d21441a
root@dlp:~#
docker ps

CONTAINER ID  IMAGE                   COMMAND      CREATED     STATUS         PORTS                NAMES
1ce587828924  srv.world/deb_apache2   "/bin/bash"  11 secon..  Up 10 seconds  0.0.0.0:8081->80/tcp cond..

# start Apache2

root@dlp:~#
docker exec 1ce587828924 /etc/init.d/apache2 start
# create a test page

root@dlp:~#
docker exec 1ce587828924 /bin/bash -c 'echo "Apache2 on Docker Container" > /var/www/html/index.html'
# verify it works normally

root@dlp:~#
curl localhost:8081

Apache2 on Docker Container
Matched Content