Ubuntu 26.04

Docker : Access to Container Services2026/05/08

 

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 example, Use a Container image which has Nginx.
root@dlp:~#
docker images

IMAGE                           ID             DISK USAGE   CONTENT SIZE   EXTRA
srv.world/ubuntu-nginx:latest   305dfeaadebc        227MB         69.9MB    U
ubuntu:latest                   f3d28607ddd7        160MB         45.3MB    U

# 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/ubuntu-nginx /usr/sbin/nginx -g "daemon off;"

3a28ef50421365cc72a9e5ec03e571a2893067a50850ac77bcad7ac9762eac2c

root@dlp:~#
docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS          PORTS                                     NAMES
3a28ef504213   srv.world/ubuntu-nginx   "/usr/sbin/nginx -g …"   10 seconds ago   Up 10 seconds   0.0.0.0:8081->80/tcp, [::]:8081->80/tcp   relaxed_hellman

# create a test page

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