Does anyone know how to specify username / password for pulling images from a private registry during a docker stack deploy? I want to be able to do this in one command:
docker stack deploy --compose-file docker-compose.yml --username <user> --password <pass> mystack
Without this, I first have to do a
docker login -u <user> -p <pass> <registry-url>
Can this be done in one command?
This worked for me, I had a private repo on dockerhub
docker login -u <<UserName>> -p <<Password>>
registry.hub.docker.com/<<Repo_Name>>
&& docker stack deploy -c docker-swarm.yml mystack --with-registry-auth
The key is to pass Username Password along with registry name and then followed it up with this flag --with-registry-auth
Here is the link which provides step by step information.
I think it cannot do it in one command typically, but you can configure private registry for clients with specific ip without authentication if you insist.
Or you can just do it in different commands but one line:
$ docker login -u <user> -p <pass> <registry-url> && docker stack deploy --compose-file docker-compose.yml mystack
The issue Use SSH pub key in order to allow access to a repository #531 address the ability to connect to an repository using SSH and keys. It's a best way to mantain security and privacity.
But you can create a read only user to perform that. If you automate the process, you can recreate de user, or change password, by the way, you can choose any turn around to solve that.