Docker : Access to Container Services2019/04/25 |
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/ubuntu_apache2 /usr/sbin/apachectl -D FOREGROUND 38ae5c950273f78e221f1efae114ea857f5fe8545814c81f0e78d8cb89f1dba0root@dlp:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 38ae5c950273 srv.world/ubuntu_apache2 "/usr/sbin/apachectl…" 22 seconds ago Up 21 seconds 0.0.0.0:8081->80/tcp determined_bose # create a test page root@dlp:~# docker exec 38ae5c950273 /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 |
|