Ubuntu 20.04
Sponsored Link

Docker : Access to Container Services
2020/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 which has Nginx.
# start the 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/ubuntu_nginx /usr/sbin/nginx -g "daemon off;"

0cd1604f1f625cb7e200ba98ef1cc87f82534a55cc1d895b92606437e9ae8681

root@dlp:~#
docker ps

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                  NAMES
0cd1604f1f62        srv.world/ubuntu_nginx   "/usr/sbin/nginx -g …"   4 seconds ago       Up 3 seconds        0.0.0.0:8081->80/tcp   elegant_edison

# create a test page

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

root@dlp:~#
curl localhost:8081

Nginx on Docker Container
Matched Content