微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nginx – 我的docker容器没有在Docker for Windows(使用Hyper-V的Native)上的localhost(0.0.0.0)上启动

我正在关注如何启动Nginx docker容器的Digital Ocean’s tutorial(目前在第4步).目前这是他们的输出

$docker run --name docker-Nginx -p 80:80 -d Nginx
d3ccb73a91985651ec61231bca9f9c716f0dec807e354a29eeef2144f883a01c

$docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                         NAMES
b91f3ce26553        Nginx               "Nginx -g 'daemon off"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp,443/tcp   docker-Nginx

但是当我运行它时,这是我的输出(注意到容器的不同IP):

C:\>docker run --name docker-Nginx -p 80:80 -d Nginx
d3ccb73a91985651ec61231bca9f9c716f0dec807e354a29eeef2144f883a01c

C:\>docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                           NAMES
d3ccb73a9198        Nginx               "Nginx -g 'daemon off"   14 hours ago        Up 2 seconds        10.0.75.2:80->80/tcp,443/tcp   docker-Nginx

为什么会这样?我怎样才能获得与Digital Ocean相同的结果? (让服务器在localhost上启动)

编辑:我正在使用Docker for windows(最近发布),显然使用Hyper-V运行本机.我对docker-machine ls的输出是这样的:

C:\>docker-machine ls
NAME   ACTIVE   DRIVER   STATE   URL   SWARM   DOCKER   ERRORS

C:\>

But when I run it,this is my output (noticed the different IP of the
container)

由于这是一台Windows机器,我假设您使用的是Docker ToolBox Docker for Windows. 10.0.75.2是boot2docker虚拟机的IP.

如果您使用的是Windows或Mac OS,则需要使用某种形式的虚拟化
为了运行Docker.您刚看到的IP是该轻量级虚拟机的IP.

And how can I get the same results as Digital Ocean’s? (Getting the
server to start on localhost)

使用Linux发行版!您还可以在Docker For Windows设置中的localhost上启用Expose容器端口:

enter image description here

原文地址:https://www.jb51.cc/hyper-v/434727.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐