Debian 11 Bullseye
Sponsored Link

Docker : Access to Container Services2021/08/30

 
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]

root@dlp:~#
docker run -t -d -p 8081:80 srv.world/debian-nginx /usr/sbin/nginx -g "daemon off;"

eef50a9f51ac62784c10c8f24a534efca678293ae37d787512aea238ff44e91b

root@dlp:~#
docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS         PORTS                  NAMES
eef50a9f51ac   srv.world/debian-nginx   "/usr/sbin/nginx -g …"   8 seconds ago   Up 6 seconds   0.0.0.0:8081->80/tcp   silly_mccarthy

# create a test page

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