How to specify username and password when pressing docker?

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 any way to specify the username and password on docker push ?

+7
docker docker-registry
source share
3 answers

I think they save passwords from the command line for security reasons.

The way to do this is to log in first and then click.

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

 $ docker login --username=maryatdocker --email=mary@docker.com Password: WARNING: login credentials saved in C:\Users\sven\.docker\config.json Login Succeeded 

Then click

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

Usually you specify your password using an interactive docker login , then do docker push .

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

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

Travis CI docs for docker builds gives an example of how to automate login to docker .

See docker login for details.

+6
source share

As far as I know, you should use docker login . /home/รนser/.docker/config.json will be stored in /home/รนser/.docker/config.json for the next docker push es.

If you are after automation, you will be interested in the expect .

0
source share

All Articles