---
title: "Discussion on \"Push your Docker containers from GitLab to Amazon ECR\" | Hashnode"
description: "Discussion on \"Push your Docker containers from GitLab to Amazon ECR\". If you are looking to store your Docker containers online in a secure way, take a try with Amazon ECR (Elastic Container Registry)\nIt is not a complicated process but there are a few pitfalls to avoid. In this post you will find a simple but function..."
url: "https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Push your Docker containers from GitLab to Amazon ECR](https://devops.dina.ch/push-your-docker-containers-from-gitlab-to-amazon-ecr?utm_source=hashnode&utm_medium=feed)

If you are looking to store your Docker containers online in a secure way, take a try with Amazon ECR (Elastic Container Registry) It is not a complicated process but there are a few pitfalls to avoid. In this post you will find a simple but function...

Jan 11, 2021 · 7 min read · devops.dina.ch  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#docker](https://hashnode.com/tag/docker)
-   [#gitlab](https://hashnode.com/tag/gitlab)
-   [#yaml](https://hashnode.com/tag/yaml)
-   [#ci](https://hashnode.com/tag/ci)

## Written by

[DINA](https://hashnode.com/@cisel)

@cisel · Switzerland

  
[View profile](https://hashnode.com/@cisel)

DevOps team

## Responses 5

Markdown supported · ⌘↵ to post

[Kavitha Ranga](https://hashnode.com/@cicd)

[Nov 14, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/61919370770afc563f667c00)

hi, I get the error **_ERROR: Cannot connect to the Docker daemon at tcp://docker:2376. Is the docker daemon running?_**

Also tried the same with port 2375 with no luck. For this to work, should Gitlab runner be running in privileged = true mode?

Any suggestions. thanks,

[DINA](https://hashnode.com/@cisel)

[Nov 17, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/61919370770afc563f667c00#reply-6195153390fac127e6ea4f0a)

Hi Kavitha, Do you have docker on the image of your stage where you're trying to build your docker container ? Here we use a dind service (docker in docker) :

```
publish:
  stage: build
  image: 
    name: docker:latest
  services:
    - docker:19-dind
```

Hope it helps ! Best regards

[RAMJOS](https://hashnode.com/@RAMJOS)

[Aug 21, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/61210b35e404793819ca9692)

Great tutorial on GITLAB and ECR.

May I know what will be next after putting the image in the image repository? Perhaps you can send me link on how the app container be deployed on the target environment. Thank you. More power

[DINA](https://hashnode.com/@cisel)

[Aug 30, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/61210b35e404793819ca9692#reply-612c841e2858872661b9cda2)

Hi RAMJOS ! Thank's for the comment ! Yes ofc, after putting the image in the repo, you can deploy it on Kubernetes. We have an other article for that : [devops.cisel.ch/deploy-argocd-and-a-first-app-on-…](https://devops.cisel.ch/deploy-argocd-and-a-first-app-on-kubernetes)

Hope it helps ! Best regards

[Dan Stein](https://hashnode.com/@happy-machine)

[May 8, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/609717031ea29f2c341e08e8)

Thanks for this!

Im getting the error: Could not connect to the endpoint URL: "[api.ecr.eu-east-2.amazonaws.com/"](https://api.ecr.eu-east-2.amazonaws.com/%22) Error: Cannot perform an interactive login from a non TTY device

Do you have any idea whats going wrong? All the env variables are populated correctly have tested theyre coming through

[DINA](https://hashnode.com/@cisel)

[May 17, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/609717031ea29f2c341e08e8#reply-60a25848b66a0b15ebfcb58a)

Hi, Are you sure that your env variables are populated correctly on the right repo (each repo needs to have it's own environment variables set up) ? Can you try in local with the command aws ecr get-login-password ? It would help you to find out the problem. Maybe you need to upgrade your awscli or maybe there is a problem with the --region.

Hope it helps ! Best regards

[Lucas](https://hashnode.com/@lucas-ordonez)

[Apr 15, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/6077935f4155da32fc83b4bd)

Hi I try with this yml and I'm getting this error:

$ aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER\_REGISTRY Unable to locate credentials. You can configure credentials by running "aws configure". Error: Cannot perform an interactive login from a non TTY device

I already setup the aws key and secret variables in ci/cd settings on gitlab.

Someone know how to resolve it?

I'm using on premise server with a gitlab runner docker with executor docker.

Thanks.

[DINA](https://hashnode.com/@cisel)

[Apr 27, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/6077935f4155da32fc83b4bd#reply-6087c6b4b81aa72681392895)

Hi Lucas, Thank's for your comment. Did you try to run an aws configure and a login from a terminal to be sure that your access are ok ?

Can you check that your variables are configured in the right gitlab project ? If it's the case, can you try to rename your variable in gitlab with an other name ? For example, rename AWS\_ACCESS\_KEY\_ID to AMAZON\_ACCESS\_KEY\_ID and try again to see if there is a difference in your error message.

Hope it helps ! Best regards

[ub1k](https://hashnode.com/@ub1k)

[May 18, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/6077935f4155da32fc83b4bd#reply-60a3d2e9b7d0a531c6aa71d7)

for me it was that the AWS\_ACCESS\_KEY\_ID were created as "protected". if you're not running the pipeline from protected branch (which I suppose you don't) then these vars are not exposed. just disable the "protected" checkbox

[DINA](https://hashnode.com/@cisel)

[May 19, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/6077935f4155da32fc83b4bd#reply-60a4c86959b7dc409c3d2d98)

[ub1k](https://hashnode.com/@ub1k) Thank's for sharing !

[hatem ben tayeb](https://hashnode.com/@btx)

[Jan 11, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/5ffc78fba538d001351571cf)

Nice work! I suggest creating your own image that contains aws-cli, get rid of variables on top and put it into GitLab as secrets to make the pipeline more simple and readable.

[DINA](https://hashnode.com/@cisel)

[Jan 12, 2021](https://hashnode.com/posts/push-your-docker-containers-from-gitlab-to-amazon-ecr/5ffc7523aa5c467fe155b129/comment/5ffc78fba538d001351571cf#reply-5ffd75cb14d2f06c78ddf685)

Thank you for your comments and suggestions. You are absolutely right! We thought that showing the various variables and the use of awscli in the code might help to better understand the process.
