title: Building and pushing docker image from Gitlab-CI to Amazon AWS ECR
body: <p>I have a private Gitlab hosted on my own machine. I store my code in Gitlab and would like to build a Docker image from the Dockerfile and push it after that to my Amazon ECR registry. Unfortunately, this does not work because it throws an error: </p>
  
  <pre><code>Flag --email has been deprecated, will be removed in 1.13.
  Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  /dev/mapper/control: open failed: Operation not permitted
  Failure to communicate with kernel device-mapper driver.
  Check that device-mapper is available in the kernel.
  Command failed
  mount: permission denied
  Could not mount /sys/kernel/security.
  AppArmor detection and --privileged mode might break.
  mkdir: cannot create directory '/sys/fs/cgroup/name=systemd': Read-only file system
  mount: mount point /sys/fs/cgroup/name=systemd is not a directory
  ln: failed to create symbolic link '/sys/fs/cgroup/systemd/name=systemd': Read-only file system
  
  Timed out trying to connect to internal docker host.
  </code></pre>
  
  <p>The gitlab-ci code looks like this: </p>
  
  <pre><code>stages:
    - build
  
  build_airflow:
    stage: build
    only: [master, develop]
    image: gitlab/dind:latest
    services:
      - docker:dind
    script:
      - APP=airflow
      - sh ./scripts/login-ecs.sh my_fancy_project
  </code></pre>
  
  <p>The login-ecs.sh script is simply executing <code>eval $(/usr/local/bin/aws ecr get-login --region eu-central-1)</code>, which should login the image to the ECR docker registry (source: <a href="https://blog.madisonhub.org/gitlab-ci-build-how-to-login-to-ecr/" rel="noreferrer">https://blog.madisonhub.org/gitlab-ci-build-how-to-login-to-ecr/</a>). </p>
  
  <p>I can not find the problem, so I hope that you can help me. </p>
  
  <p>Thank you in advance. </p>
  
  <p>PS: If I execute the command from the <code>aws ecr get-login</code> locally, it works fine. So it should have to do something with the gitlab. Does I have to change some configurations that private registry logins are allowed? </p>