# Docker stack deploy no basic auth credentials

**URL:** <https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734>\
**Category:** General\
**Tags:** aws, docker, amazonwebservices\
**Created:** [January 29, 2017, 8:09pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734 "2017-01-29T20:09:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wannaknowmo](https://avatars.discourse-cdn.com/v4/letter/w/e480ec/32.png) [@wannaknowmo](https://forums.docker.com/u/wannaknowmo)\
**Post date:** [January 29, 2017, 8:09pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/1 "2017-01-29T20:09:42Z")

</div>

### Expected behavior

would like to know how to pull an image from an aws ecr repo while running a doker stack deploy cmd.  
how do you translate the following param --with-registry-auth in the docker compose v3 file?  
i’m able to create a service from the cmd line but i had no success with docker-compose v3.

### Actual behavior

eval $(aws ecr get-login --region us-east-1)  
Flag --email has been deprecated, will be removed in 1.14.  
Login Succeeded

ls -rlt config.json  
-rw-------. 1 root root 1592 Jan 29 13:52 config.json  
docker stack deploy -c test.yml QA\_STATUS

from /var/log/messages  
Jan 29 13:57:42 XXXXX dockerd: time=“2017-01-29T13:57:42.487088958-06:00” level=warning msg=“unable to pin image [XXXXX.us-east-1.amazonaws.com/docker-dev-repo:lighttpd](http://XXXXX.us-east-1.amazonaws.com/docker-dev-repo:lighttpd) to digest: Head [https://XXXXXX.ecr.us-east-1.amazonaws.com/v2/docker-dev-repo/manifests/lighttpd:](https://XXXXXX.ecr.us-east-1.amazonaws.com/v2/docker-dev-repo/manifests/lighttpd:) no basic auth credentials”

### Additional Information

docker version  
Client:  
Version: 1.13.0  
API version: 1.25  
Go version: go1.7.3  
Git commit: 49bf474  
Built: Tue Jan 17 09:55:28 2017  
OS/Arch: linux/amd64

Server:  
Version: 1.13.0  
API version: 1.25 (minimum version 1.12)  
Go version: go1.7.3  
Git commit: 49bf474  
Built: Tue Jan 17 09:55:28 2017  
OS/Arch: linux/amd64  
Experimental: false

### Steps to reproduce the behavior

1. eval $(aws ecr get-login --region us-east-1)
2. docker stack deploy -c test.yml QA\_STATUS

---

<div class="post-metadata">

**Author:** ![ambrons](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ambrons/32/15059_2.png) [@ambrons](https://forums.docker.com/u/ambrons)\
**Post date:** [January 30, 2017, 3:41pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/2 "2017-01-30T15:41:16Z")

</div>

See my answer here:

> [@Can't pull images from AWS ECR repository](https://forums.docker.com/t/cant-pull-images-from-aws-ecr-repository/27596/4):
>
> Per the documentation on accessing the Manager remotely you can do this locally: ssh -i aws-host-key-file -NL localhost:2374:/var/run/docker.sock docker@\<docker-manager-public-ip\> & Then i used my local aws install: aws ecr get-login --region us-east-1 And modified there response to include the -H localhost:2374, like so: docker -H localhost:2374 login -u AWS -p \<token\> -e none https://\<registry-url\> Then you can create a stack like so that works with ECS included in the yaml: docker -H l…

---

<div class="post-metadata">

**Author:** ![wannaknowmo](https://avatars.discourse-cdn.com/v4/letter/w/e480ec/32.png) [@wannaknowmo](https://forums.docker.com/u/wannaknowmo)\
**Post date:** [January 30, 2017, 6:21pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/3 "2017-01-30T18:21:00Z")

</div>

i’m able to create a service from the cmd line. just wondering how you do it using the docker compose yaml file.  
how do you parse the token in yaml file?

---

<div class="post-metadata">

**Author:** ![ambrons](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ambrons/32/15059_2.png) [@ambrons](https://forums.docker.com/u/ambrons)\
**Post date:** [January 30, 2017, 6:42pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/4 "2017-01-30T18:42:18Z")

</div>

We don’t parse the token in the yaml file. From my understanding of `docker stack deploy` the `--compose-file` option is to allow you to skip the step of having to create a bundle (dab) file. I could be misinterrupting what you’re asking, but it sounds like you want to bake the authentication for connecting to a private repo directly into the yaml file. To my knowledge that isn’t possible.

We are evaluating Docker for AWS as an alternative to our current deployment via EC2 Container Service. In ECS this is just automatic via Roles and Policies given to our InstanceProfile.

Initially before I tried the above _workaround_ I attempted to add the ECR ReadOnly policy to the DockerForAWSProxy InstancePolicy from their CloudFormation. That didn’t work and I’m not entirely sure why. However I think that’s the _best_ solution when you are using DockerForAWS + ECR.

---

<div class="post-metadata">

**Author:** ![wannaknowmo](https://avatars.discourse-cdn.com/v4/letter/w/e480ec/32.png) [@wannaknowmo](https://forums.docker.com/u/wannaknowmo)\
**Post date:** [January 30, 2017, 9:35pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/5 "2017-01-30T21:35:01Z")

</div>

how do aws credential get parse with docker stack deploy ?

---

<div class="post-metadata">

**Author:** ![wannaknowmo](https://avatars.discourse-cdn.com/v4/letter/w/e480ec/32.png) [@wannaknowmo](https://forums.docker.com/u/wannaknowmo)\
**Post date:** [January 31, 2017, 1:54am UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/6 "2017-01-31T01:54:21Z")

</div>

@ambrons

a simple  
eval $(aws ecr get-login --region us-east-1)  
docker stack deploy -c test.yml QA\_STATUS --with-registry-auth

did it for me!

thanks for your help

---

<div class="post-metadata">

**Author:** ![ambrons](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ambrons/32/15059_2.png) [@ambrons](https://forums.docker.com/u/ambrons)\
**Post date:** [January 31, 2017, 2:43pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/7 "2017-01-31T14:43:18Z")

</div>

@wannaknowmo that’s great! Glad I could help.

Note there’s an issue with ERC + Docker Swarm thought. The token / password given to you when you run `aws ecr get-login...` is only good for 12 hours. So if Docker scheduling has to redeploy or replace, etc, etc your application after 12 hours it’ll likely fail to load.

So just keep in mind even though this works it probably not production viable. I’m going to did into seeing if there’s a way to assign the workers and manger of docker swarm access to ECR without having to provide credentials. I believe this is the way that ECS and EB work.

---

<div class="post-metadata">

**Author:** ![simdrouin](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@simdrouin](https://forums.docker.com/u/simdrouin)\
**Post date:** [June 1, 2017, 3:49pm UTC](https://forums.docker.com/t/docker-stack-deploy-no-basic-auth-credentials/27734/8 "2017-06-01T15:49:28Z")

</div>

@ambrons, did you find a viable solution to this problem?

Thank you!
