Build 2 Docker images on the same machine

Hello all,

I have 2 Dockerfile in my repo, and this is my config.yml

jobs:
  build-and-push-images:
    machine:
      image: "ubuntu-2004:202010-01"
    steps:
      - checkout
      - aws-ecr/build-and-push-image:
          repo: mymodel
          path: ~/project/training
          tag: training
          checkout: false
      - aws-ecr/build-and-push-image:
          repo: mymodel
          path: ~/project/predict
          tag: predict
          checkout: false

The 2 Dockerfile:

  • training/Dockerfile with content
FROM python:3.8
# some other steps

Once the docker image finish building, we will tag it mymodel:training

  • predict/Dockerfile with content
# using it from tag from the previous docker build step
FROM mymodel:training
# some other steps

But then I got this error in CircleCI

Sending build context to Docker daemon  23.04kB
Step 1/4 : FROM mymodel:training
pull access denied for mymodel, repository does not exist or may require 'docker login'

Exited with code exit status 1

I realize this is probably because training and serving are not building on the same machine, is there a way to force it?

The issue is that you need to prepend your AWS repository to the image name. It will look something like

FROM <account id>.dkr.ecr.<region>.amazonaws.com/mymodel:training

in the end. Notice how the tag is constructed in the orb source.

You might consider adding a quick debugging step to your job, which will also help you find the image repository:

run:
  name: List Docker images
  command: docker image ls