tmp_qa tmp_qa - 9 months ago 107
Linux Question

automatic docker login within a bash script

How can I preseed my credentials to

docker login
command within a script ?

I'm using a bash script that basically automates the whole process of setting up my custom VMs etc, but when I need to login to docker within the script to pull the images, I get the following error:

Username: FATA[0000] inappropriate ioctl for device

The command I was using is the following:

( echo "xxx"; echo "yyy"; echo "zzz" ) | docker login

Is this possible to achieve without using and coping over an existing
file and how,

Many thanks.


You can pass all the arguments on the command-line:

docker login --username=$DOCKER_USER --password=$DOCKER_PASS $DOCKER_HOST

If you don't specify DOCKER_HOST, you'll get the main Docker repo. If you leave out any of the arguments, you'll be prompted for that argument.

(For versions of Docker older that 1.11, you need to pass an --email flag, but its contents are not actually checked)