wasapl on 16 Jun, 2018 07:30 PM
describes several ways to provide a password to docker command.
In part "Provide a password using STDIN" there is a quite simple example:
$ cat ~/my_password.txt | docker login --username foo --password-stdin But If you don't want to write password to file and you store it in variable $docker_password you may rewrite this example like this:
docker login --username foo --password-stdin <<< "$docker_password"
There is "Credentials store" and "Credential helper protocol" parts of https://docs.docker.com/engine/reference/commandline/login/ also worth to read,
But frankly, do not use dollar sign in bash strings. This will save you a lot of time ;))