How to authenticate for docker push?

Jas picture Jas · Dec 23, 2015 · Viewed 90.2k times · Source

Hi i'm trying docker push

[docker-simple-httpserver]# docker push myregistry/simplehttpserver:latest
The push refers to a repository [myregistry/simplehttpserver] (len: 1)
Sending image list
FATA[0000] Error: Status 403 trying to push repository simplehttpserver: "{\"error\": \"Unauthorized updating repository images\"}" 

is there a way for me to specify the username and password on docker push command?

Answer

KeepCalmAndCarryOn picture KeepCalmAndCarryOn · Dec 23, 2015

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