Ubuntu 18.04
Sponsored Link

Docker : Access to Container Services2018/06/12

 
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 exmaple, use a Container which has Apache2.
# start the Container and also run Apache2

# 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/ubuntu_apache2 /usr/sbin/apachectl -D FOREGROUND

dfac51718b61f7814464b9fa4f6b21725e5836486ce3bf8c45caa4e7a1332623
root@dlp:~#
docker ps

CONTAINER ID   IMAGE                     COMMAND             CREATED         STATUS          PORTS                  NAMES
dfac51718b61   srv.world/ubuntu_apache2  "/usr/sbin/apac…"   10 seconds ago  Up 10 seconds   0.0.0.0:8081->80/tcp   sleepy_brattain

# create a test page

root@dlp:~#
docker exec dfac51718b61 /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