# Docker Login with --password-stdin (2.0)

**URL:** <https://discuss.circleci.com/t/docker-login-with-password-stdin-2-0/18477>\
**Category:** Build Environment\
**Tags:** docker\
**Created:** [December 1, 2017, 1:22am UTC](https://discuss.circleci.com/t/docker-login-with-password-stdin-2-0/18477 "2017-12-01T01:22:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderNZ](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/alexandernz/32/9789_2.png) [@AlexanderNZ](https://discuss.circleci.com/u/AlexanderNZ)\
**Post date:** [December 1, 2017, 1:22am UTC](https://discuss.circleci.com/t/docker-login-with-password-stdin-2-0/18477/1 "2017-12-01T01:22:09Z")

</div>

Hi all,

I’m new to CircleCI and am wondering if anyone has found an elegant solution to this problem:

I’m building a docker image and pushing to a private repo on docker hub, which means I need to log in to docker.

I’ve tried the docker login syntax with -u and -p (ie docker login -u username -p password) and docker rejects my login. [https://docs.docker.com/engine/reference/commandline/login/#extended-description](https://docs.docker.com/engine/reference/commandline/login/#extended-description) describes why this is the case and provides an example of standard in usage with:

cat ~/my\_password.txt | docker login --username foo --password-stdin

In CircleCI context, this to me means that I need to save my docker password to a file, in my repo. Which I really don’t want to do.

My question then is how have people worked around this, has anyone seen a nice solution?  
I’ve had a think about using circle contexts aka environment variables, but this would still not be piping in from std in so am a bit confused as to the best way of doing this.

I’d love any advice you more experience circleci people have 🙂

I’m using Node 7.10.0 to package an Ionic Web App, and Java 8 for a spring boot API  
Docker on circle is giving me a message that my password is invalid (it’s not) because it wants the input via std in as per docs linked above  
The specific step is

```
  - run:
      name: Docker Login
      command: 'docker login -u MYUSERNAME -p MYPASSWORD'

```

Thanks all 🙂

---

<div class="post-metadata">

**Author:** ![stmllr](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/stmllr/32/13846_2.png) [@stmllr](https://discuss.circleci.com/u/stmllr)\
**Post date:** [December 1, 2017, 10:07am UTC](https://discuss.circleci.com/t/docker-login-with-password-stdin-2-0/18477/2 "2017-12-01T10:07:37Z")

</div>

1. Add your docker credentials to the project environment variables. (Build settings -\> environment variables). Use DOCKER\_USER and DOCKER\_PASS as name for the variables
2. Alter your command to: `docker login -u $DOCKER_USER -p $DOCKER_PASS`

See:[https://circleci.com/docs/2.0/building-docker-images/](https://circleci.com/docs/2.0/building-docker-images/)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:40am UTC](https://discuss.circleci.com/t/docker-login-with-password-stdin-2-0/18477/3 "2018-06-18T11:40:07Z")

</div>

Closed on June 18, 2018, 11:40am UTC


