简体   繁体   English

如何在docker-compose 3中使用docker deploy?

[英]How to use docker deploy in docker-compose 3?

When I make command sudo docker stack deploy -c docker-compose.yml test 当我发出命令sudo docker stack deploy -c docker-compose.yml test

Ignoring unsupported options: build, external_links, links, restart

Updating service test_cache (id: me2vh1lffrl4ppzomphin167la)
Updating service test_lb (id: ycnne1ifpt517wdbfdg1g5tlup)
Updating service test_media (id: rr3ural9hjz0mw6hjx7n2vywm)
Creating service test_web

Error response from daemon: rpc error: code = 3 desc = ContainerSpec: image reference must be provided

And I get this error - Error response from daemon: rpc error: code = 3 desc = ContainerSpec: image reference must be provided 我收到此错误 - 来自守护程序的错误响应:rpc错误:代码= 3 desc = ContainerSpec:必须提供图像引用

But I create image for this container. 但我为这个容器创建了图像。

Your compose.yml file does not include an image section which is required by docker stack deploy . 您的compose.yml文件不包含docker docker stack deploy所需的映像部分。 You should also be pushing these images to a registry server if you are deploying them to a swarm since docker uses pinning to the sha256 of the image in the registry to ensure all nodes run the same image. 如果要将这些映像部署到群中,则还应该将这些映像推送到注册表服务器,因为docker使用固定到注册表中映像的sha256以确保所有节点都运行相同的映像。 And since swarm does not build the images, any node without the image included locally will not be able to run this image unless it's pulled from a registry. 并且由于swarm不构建图像,所以没有本地包含图像的任何节点将无法运行此图像,除非它从注册表中拉出。

This is late, but I'd like to say that I got this error when I had a comment in the docker-compose.yml file, like this: 这已经很晚了,但我想说当我在docker-compose.yml文件中发表评论时出现了这个错误,如下所示:

version: "3"
services:
  web:
    # pull the image from repository
    image: myname/docker-private:testproj
    ...

However, the comment needs to start at the first character of the line: 但是,评论需要从该行的第一个字符开始:

version: "3"
services:
  web:
# pull the image from repository
    image: myname/docker-private:testproj
    ...

This fixed the problem. 这解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM