Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: How to authenticate for docker push?

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?

like image 495
Jas Avatar asked Dec 23 '15 11:12

Jas


People also ask

How do I use docker to push?

To push an image to Docker Hub, you must first name your local image using your Docker Hub username and the repository name that you created through Docker Hub on the web. You can add multiple images to a repository by adding a specific :<tag> to them (for example docs/base:testing ).


2 Answers

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 
like image 198
KeepCalmAndCarryOn Avatar answered Oct 11 '22 06:10

KeepCalmAndCarryOn


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 gives an example of how to automate a docker login.

See docker login for more details.

like image 26
seveibar Avatar answered Oct 11 '22 05:10

seveibar