Docker: Swarm worker nodes not finding locally built image -
maybe missed something, made local docker image. have 3 node swarm , running. 2 workers , 1 manager. use labels constraint. when launch service 1 of workers via constraint works if image public.
that is, if do:
docker service create --name redis --network my-network --constraint node.labels.myconstraint==true redis:3.0.7-alpine
then redis service sent 1 of worker nodes , functional. likewise, if run locally built image without constraint, since manager worker, gets scheduled manager , runs well. however, when add constraint fails on worker node, docker service ps 2l30ib72y65h
see:
... shutdown rejected 14 seconds ago "no such image: my-customized-image"
is there way make workers have access local images on manager node of swarm? use specific port might not open? if not, supposed - run local repository?
the manager node doesn't share out local images itself. need spin registry server (or user hub.docker.com). effort needed isn't significant:
# first create user, updating $user environment: if [ ! -d "auth" ]; mkdir -p auth fi chmod 666 auth/htpasswd docker run --rm -it \ -v `pwd`/auth:/auth \ --entrypoint htpasswd registry:2 -b /auth/htpasswd $user chmod 444 auth/htpasswd # spin 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 # push image docker login localhost:5000 docker tag my-customized-image localhost:5000/my-customized-image docker push localhost:5000/my-customized-image # spin service new image name # replace registryhost ip/hostname of registry docker host docker service create --name custom --network my-network \ --constraint node.labels.myconstraint==true --with-registry-auth \ registryhost:5000/my-customized-image
Comments
Post a Comment