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?