I’ve just started using Docker for AWS and I got a stack up running with 3 manager nodes and 5 cluster nodes. Getting the stack running worked just fine. But for some reason I can’t get my own built image to run on AWS, however it works just fine locally. The image is located in a private docker hub repo. I’ve added the with-registry-auth flag when creating the service on the management node but with no success so far. The service is started but the number of replicas is never increased.
The commands run:
# Locally
$ docker build -t mycompany/myweb:0.0.1 .
# Check that it works as expected locally
$ docker run --rm -it --name myweb-web -P mycompany/myweb:0.0.1
$ docker push mycompany/myweb-web:0.0.1
Then I log into a management node using SSH and do:
$ docker login --username=mycompany --email=email@mycompany.net
$ docker service create --name myweb-web --with-registry-auth --replicas 3 --publish 80:80 mycompany/myweb-web
$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
80xilds358u5 myweb-web 0/3 mycompany/myweb-web
For some reason the replicas are never created. Note, when trying with launching a container like nginx from a public repo, it works.
UPDATE: When using docker services ps <serviceid> it seems that the image isn’t found. The error column says: No such image: mycompany/myweb-web…. But it will be fetched from Docker Hub when running locally.
UPDATE 2: I just recreated the whole stack and made the image public then it works. I will do it over again, recreate the stack and try to create the service with the private image.
After testing with the image both in a private and public repository, logging in to Docker Hub right before creating the service and using the --with-registry-auth flag I could only get the public image to work.
That’s very strange, I just tried to reproduce. It doesn’t work without login nor --with-registry-auth for me either, but it works correctly with:
docker service create --name test -p 80:80 --with-registry-auth friism/foo-vote
(that’s a private image)
Maybe it’s some sort of company vs. your personal login problem? Could you try with a private image that’s tied to you hub account (vs. your company’s)?
I got it working the day after for some reason. I did the exact steps as before using same script as the day before - created the stack, logged in via ssh and from there logged in to DockerHub and then created the service with registry auth flag.
I created the DockerHub account the very same day I started testing. I recreated the stack a few times and services without success.
I ran into the same problem again - replicas are not increasing as the image can not be found when creating a service, but I got some more info about it.
As part of a evaluation of a service setup I’m using the free DockerHub which includes one free private repo. Some weeks ago when this error showed up, I created a new private repo and pushed an image to that repo. The same day I setup a cloudformation stack and tried to create a service using the image but got the error that the image could not be found. However, the day after it worked just fine to create the service, the image was found at DockerHub.
Today I did something similar. In AWS I created a new cloudformation stack. In DockerHub I removed the old private repo and added a new one with a new name. Then I pushed a new image to the private repo. When creating the service I got the same error as before - “No such image: company/image…”. Hence the replicas are not increasing.
I will try to create the service with the new image later on today or tomorrow to see if it is consistent with the previous behaviour. There seem to be some delay when images are visible.
What is more interesting is that the image from the old private repo - the repo and image that I deleted - could be used for creating a service today.
UPDATE:
After further investigation - have I misunderstood how images are fetched? Is it mandatory to always use a tag when creating a service? For example if I add an image with tag 0.0.1 and I try to create a service using
docker service create --with-registry-auth company/repo
Will this fetch the latest image from the repo, ie image with tag 0.0.1? Or do I have to tag the latest image with the tag latest for this to work?
Ok, this is my bad - omitting the label of an image when creating a service will not install the image.