Docker : Access to Services on Container2019/02/19 |
If you'd like to access to services like HTTP or SSH which is running on Containers as a daemon, set like follows.
|
|
[1] | For exmaple, run a container to use the container image which has IIS service like the example of here. |
# map the port of Host and the port of Container with [-p xxx:xxx] PS C:\Users\Administrator> docker run -t -d -p 8081:80 srv.world/iis cmd
ce3bfb401c6ea52f1f640fc5141932017515366d75acfb902405cbe569ca0d92PS C:\Users\Administrator> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ce3bfb401c6e srv.world/iis "cmd" 32 seconds ago Up 27 seconds 0.0.0.0:8081->80/tcp blissful_nobel # create a test page PS C:\Users\Administrator> docker exec ce3bfb401c6e powershell -c "Write-Output 'IIS on Docker Container' | Out-File -Encoding default C:\inetpub\wwwroot\index.html"
|
[2] | Verify the test page is shown normally to access to [localhost:8081] on Parent Host. |
Sponsored Link |
|