Sponsored Link

Docker : Access to Services on Container2019/01/22

If you'd like to access to services like HTTP or SSH which is running on Containers as a daemon, Configure like follows.
[1] For exmaple, use a Container which has httpd.
# start the Container and also run httpd

# map the port of Host and the port of Container with [-p xxx:xxx]

dlp:~ #
docker run -t -d -p 8081:80 /usr/sbin/httpd -D FOREGROUND

dlp:~ #
docker ps

CONTAINER ID    IMAGE                    COMMAND                  CREATED             STATUS           PORTS                  NAMES
1a5d1a77c702   "/usr/sbin/httpd -D …"   27 seconds ago      Up 26 seconds>80/tcp   stoic_curran

# create a test page

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

dlp:~ #
curl localhost:8081

httpd on Docker Container
Matched Content