Docker:Swarm工作节点找不到本地构建的图像

也许我错过了什么,但我制作了一个本地的码头图像.我有一个3节点的群集并且正在运行.两名工人和一名经理.我使用标签作为约束.当我通过约束向其中一个工作人员启动服务时,如果该图像是公开的,它将完美地工作.

也就是说,如果我这样做:

docker service create --name redis --network my-network  --constraint node.labels.myconstraint==true redis:3.0.7-alpine

然后,redis服务被发送到其中一个工作节点,并且功能完备.同样,如果我运行我的本地构建的图像没有约束,因为我的经理也是一个工人,它被安排到经理并运行得非常好.但是,当我添加约束它在工作节点上失败时,从docker service ps 2l30ib72y65h我看到:

... Shutdown       Rejected 14 seconds ago  "No such image: my-customized-image"

有没有办法让工作人员可以访问群组管理器节点上的本地图像?它是否使用可能未打开的特定端口?如果没有,我应该做什么 – 运行本地存储库?

管理器节点不会从自身共享本地映像.您需要启动注册表服务器(或用户hub.docker.com).所需的努力不是很重要:

# first create a user,updating $user for your environment:
if [ ! -d "auth" ]; then
  mkdir -p auth
fi
touch auth/htpasswd
chmod 666 auth/htpasswd
docker run --rm -it \
  -v `pwd`/auth:/auth \
  --entrypoint htpasswd registry:2 -B /auth/htpasswd $user
chmod 444 auth/htpasswd

# then spin up the registry service listening on port 5000
docker run -d -p 5000:5000 --restart=always --name registry \
  -v `pwd`/auth/htpasswd:/auth/htpasswd:ro \
  -v `pwd`/registry:/var/lib/registry \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Local Registry" \
  -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \
  -e "REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry" \
  registry:2

# then push your image
docker login localhost:5000
docker tag my-customized-image localhost:5000/my-customized-image
docker push localhost:5000/my-customized-image

# then spin up the service with the new image name
# replace registryhost with ip/hostname of your registry Docker host
docker service create --name custom --network my-network \
  --constraint node.labels.myconstraint==true --with-registry-auth \
  registryhost:5000/my-customized-image

相关文章

最近一直在开发Apworks框架的案例代码,同时也在一起修复Apw...
最近每天都在空闲时间努力编写Apworks框架的案例代码WeText。...
在《Kubernetes中分布式存储Rook-Ceph部署快速演练》文章中,...
最近在项目中有涉及到Kubernetes的分布式存储部分的内容,也...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...
CentOS下Docker与.netcore(一) 之 安装 CentOS下Docker与.ne...