3

I need a simple solution to build a docker image, push it to ECR, and deploy it to ECS.

The final part, which deploys the ECR image to ECS is working. (I'm using a deploy.py short script that uses Python's AWS boto3 SDK, found it easier than making the ECS Orb work..)

However, I'm struggling with the first part, need help. I just need to automate the simple docker build, docker tag and docker push. It's very simple, but I don't know what I'm doing wrong.

Can anyone help me? It follows the code, I'm running it locally for debug purposes:

version: '2.1'
jobs:
  build:
    docker:
      - image: cimg/python:3.8 
    environment:
      AWS_ACCESS_KEY_ID: yadayadayada
      AWS_SECRET_ACCESS_KEY: yadayadayada
      AWS_DEFAULT_REGION: yadayadayada
    steps:
      - checkout
      - run: |
          docker build -t myimg .
          docker tag myimg:latest asdf.dkr.ecr.asdf.amazonaws.com/asddf:latest
          docker push asdf.dkr.ecr.asdf.amazonaws.com/asdf:latest
          
          pip install boto3
          python deploy.py

Learnign CircleCI is really frustrating, no good resources for beginners...

Thanks in advance!

1 Answer 1

5

You need to use the setup_remote_docker special step in order to get a remote Docker engine running so that your Docker commands will work.

Learnign CircleCI is really frustrating, no good resources for beginners...

Really? You can find my answer (the "setup_remote_docker") and how to use it right on CircleCI Docs in a guide called Running Docker Commands.

I hope this helps. Also, you'll see that setting a Docker version is optional but I strongly suggest you set one. The default version is very old.

4
  • 1
    I have setup_remote_docker but am still getting this err. Any ideas what could be wrong? It works locally on my machine but not on the circleci server. Commented Dec 3, 2022 at 0:35
  • @java-addict301 were you able to fix the issue? If yes, could you please tell how did you resolve it?
    – techStud
    Commented Jul 8 at 5:52
  • @techStud I am forgetting, I'm sorry. I can tell you that my current setup is like this: docker: - image: cimg/node:20.4.0-browsers steps: - setup_remote_docker: docker_layer_caching: false version: docker24 I hope this helps you because I think this helped my issue Commented Jul 8 at 18:41
  • 1
    @techStud the other thing I remember is that using sudo (or not using sudo) in front of your docker commands can cause this. I think if circleci is running as root, you need it. If not, you shouldn't have it. Commented Jul 8 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.