How to authenticate for docker push?

I would think they keep passwords off the command line for security reasons.

The way to do it is to login first then push.

https://docs.docker.com/mac/step_six/

$ docker login --username=maryatdocker [email protected]
Password:
WARNING: login credentials saved in C:\Users\sven\.docker\config.json
Login Succeeded

Then push

$ docker push maryatdocker/docker-whale
The push refers to a repository [maryatdocker/docker-whale] (len: 1)
7d9495d03763: Image already exists
c81071adeeb5: Image successfully pushed

Typically you would specify your password using the interactive docker login then do a docker push.

For a non-interactive login, you can use the -u and -p flags.

docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"

The Travis CI docs for docker builds give an example of how to automate a docker login.

See docker login for more details.


As far as I know you have to use docker login. The credentials will be stored in /home/user/.docker/config.json for following docker pushes.

If you are after automation the command expect will be interesting for you.