Tuesday 7 June 2022

Create a Host Network for Docker Container


sudo docker run --rm -d --network host --name nginx_container nginx

Unable to find image 'nginx:latest' locally

latest: Pulling from library/nginx

Digest: sha256:2bcabc23b45489fb0885d69a06ba1d648aeda973fae7bb981bafbb884165e514

Status: Downloaded newer image for nginx:latest

57246e1dc2877dcbc128fe8e52c7d7fe9c27b5edb59f1b06ac20d6fe8d381b9d


 curl localhost

<!DOCTYPE html>

<html>

<head>

<...>

<p><em>Thank you for using nginx.</em></p>

</body>

</html>


sudo docker container inspect nginx_container | grep 'NetworkMode'

            "NetworkMode": "host",


ss -lnp | grep 0.0.0.0:80

tcp                LISTEN              0                    511                                                                                         0.0.0.0:80                                                0.0.0.0:*


No comments:

Post a Comment