Ubuntu 20.04
Sponsored Link

Docker : Access to Container Services2020/06/02

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 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]

docker run -t -d -p 8081:80 srv.world/ubuntu-nginx /usr/sbin/nginx -g "daemon off;"


docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS         PORTS                  NAMES
fdb3a02ff014   srv.world/ubuntu-nginx   "/usr/sbin/nginx -g …"   8 seconds ago   Up 8 seconds>80/tcp   priceless_pascal

# create a test page

docker exec fdb3a02ff014 /bin/bash -c 'echo "Nginx on Docker Container" > /var/www/html/index.html'
# verify it works normally

curl localhost:8081

Nginx on Docker Container
Matched Content