如何在不发布的情况下部署Docker应用程序?

时间:2018-04-28 00:22:58

标签: windows docker

如何部署Docker应用程序而不将其发布到其集线器?我不想在他们的服务上创建用户名和密码(他们只是想在他们的生态系统中捕获苍蝇),我认为我不会使用Docker的 swarm 部分。除此之外,在公共存储库上发布您的闭源代码听起来非常不安全!但是我想看看它是如何工作的,并希望学习堆栈部分,这取决于 swarm 部分。我按照他们的教程,但应用程序仅部署在本地默认主节点上。

https://docs.docker.com/get-started/part4/#deploy-the-app-on-the-swarm-manager

docker-composer.yml
...
# replace username/repo:tag with your name and image details
image: friendlyhello

3个具有1个主节点的机器/节点

C:\Temp\docker-tutorial>docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.03.1-ce
myvm1     -        virtualbox   Running   tcp://192.168.99.101:2376           v18.03.1-ce
myvm2     -        virtualbox   Running   tcp://192.168.99.102:2376           v18.03.1-ce

该应用程序部署了6个实例。

C:\Temp\docker-tutorial>docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                  PORTS
uvsxf1q7brhb        getstartedlab_web   replicated          6/6                 friendlyhello:latest   *:80->80/tcp

然而,应用程序仅落入默认主节点而没有任何群集节点。

C:\Temp\docker-tutorial>docker service ps getstartedlab_web
ID                  NAME                      IMAGE                  NODE                DESIRED STATE       CURRENT STATE                ERROR
        PORTS
6jh1ua0wjyzi        getstartedlab_web.1       friendlyhello:latest   default             Running             Running about an hour ago

to14hu7g3rhz         \_ getstartedlab_web.1   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
ek91tcdj61nv         \_ getstartedlab_web.1   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
jwdvuf89a640         \_ getstartedlab_web.1   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
xrp0rim67ipi        getstartedlab_web.2       friendlyhello:latest   default             Running             Running about an hour ago

tp008eoj2mpk        getstartedlab_web.3       friendlyhello:latest   default             Running             Running about an hour ago

w6wyk3nj53zv         \_ getstartedlab_web.3   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
7ts6aqianz7l         \_ getstartedlab_web.3   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
gjt1qks57rud         \_ getstartedlab_web.3   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
o05u4qwt12vq        getstartedlab_web.4       friendlyhello:latest   default             Running             Running about an hour ago

ifzmmy8ru443         \_ getstartedlab_web.4   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
jnxn8gs3bte3         \_ getstartedlab_web.4   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
xsooht9gpf01         \_ getstartedlab_web.4   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
v23mjl8n3yyd        getstartedlab_web.5       friendlyhello:latest   default             Running             Running about an hour ago

meocennltdph        getstartedlab_web.6       friendlyhello:latest   default             Running             Running about an hour ago

3t78bpswwuyw         \_ getstartedlab_web.6   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
y3ih3md932qo         \_ getstartedlab_web.6   friendlyhello:latest   myvm2               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"
sqsngkq1440a         \_ getstartedlab_web.6   friendlyhello:latest   myvm1               Shutdown            Rejected about an hour ago   "No such image: friendlyhello:"

Docker版本18.03.0-ce,版本0520e24302,Windows 8.1

我试图关注

https://github.com/docker/docker-registry/blob/master/README.md#quick-start
https://docs.docker.com/registry/#basic-commands
https://blog.docker.com/2013/07/how-to-use-your-own-registry/

我在docker-compose.yml

中设置了这一行
image: 192.168.99.100:5000/get-started:part2

但在我跑docker stack deploy之后,它仍然失败了!

C:\Temp\docker-tutorial>docker stack deploy -c docker-compose.yml getstartedlab
Creating network getstartedlab_webnet
Creating service getstartedlab_web

C:\Temp\docker-tutorial>docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                   PORTS
jjr7cuqy2i54        getstartedlab_web   replicated          0/6                 192.168.99.100:5000/get-started:part2   *:80->80/tcp

C:\Temp\docker-tutorial>docker service ps getstartedlab_web
ID                  NAME                      IMAGE                                   NODE                DESIRED STATE       CURRENT STATE             ERROR
                      PORTS
bsx3slkj8pbr        getstartedlab_web.1       192.168.99.100:5000/get-started:part2   myvm1               Ready               Rejected 3 seconds ago    "No such image: 192.168.99.100"
cusqg0p35cwp         \_ getstartedlab_web.1   192.168.99.100:5000/get-started:part2   default             Shutdown            Rejected 8 seconds ago    "No such image: 192.168.99.100"
...

图像位于“localhost”但不是192.168.99.100。

C:\Temp\docker-tutorial>docker pull localhost:5000/get-started:part2
part2: Pulling from get-started
Digest: sha256:fedc2e7c01a45dab371cf4e01b7f8854482b33564c52d2c725f52f787f91dbcb
Status: Image is up to date for localhost:5000/get-started:part2

C:\Temp\docker-tutorial>docker pull 192.168.99.100:5000/get-started:part2
Error response from daemon: Get https://192.168.99.100:5000/v2/: http: server gave HTTP response to HTTPS client

localhost:5000拒绝在浏览器中进行连接。我还尝试localhost:5000/get-started:part2作为图像名称,但也失败了。

1 个答案:

答案 0 :(得分:0)

您可以托管自己的docker容器注册表,也可以使用自定义身份验证的许多云提供商使用私有容器注册表。几个选项:

如果您想要完全控制,您也可以托管自己的Docker Registry

设置完注册后,您只需使用docker login进行身份验证,然后照常使用docker push/pull管理您的图片。