Docker : Access to Container Services2019/07/24 |
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 Apache2. |
# start the Container and also run Apache2 # 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_apache2 /usr/sbin/apachectl -D FOREGROUND a59a297105ac4e2edac34f530b419f4710307c51a4bbc820a462876ca18673b3root@dlp:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a59a297105ac srv.world/debian_apache2 "/usr/sbin/apachectl…" 27 seconds ago Up 25 seconds 0.0.0.0:8081->80/tcp laughing_pike # create a test page root@dlp:~# docker exec a59a297105ac /bin/bash -c 'echo "Apache2 on Docker Container" > /var/www/html/index.html'
# verify it works normally root@dlp:~# curl localhost:8081 Apache2 on Docker Container |
Sponsored Link |
|