# Build 2 Docker images on the same machine

**URL:** <https://discuss.circleci.com/t/build-2-docker-images-on-the-same-machine/38097>\
**Category:** Build Environment\
**Tags:** docker, circle-yml\
**Created:** [November 12, 2020, 3:22am UTC](https://discuss.circleci.com/t/build-2-docker-images-on-the-same-machine/38097 "2020-11-12T03:22:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samxiao](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/samxiao/32/25960_2.png) [@samxiao](https://discuss.circleci.com/u/samxiao)\
**Post date:** [November 12, 2020, 3:22am UTC](https://discuss.circleci.com/t/build-2-docker-images-on-the-same-machine/38097/1 "2020-11-12T03:22:54Z")

</div>

Hello all,

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

```auto
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

```auto
FROM python:3.8
# some other steps

```

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

- `predict/Dockerfile` with content

```auto
# using it from tag from the previous docker build step
FROM mymodel:training
# some other steps

```

But then I got this error in CircleCI

```auto
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?

---

<div class="post-metadata">

**Author:** ![simon-swanson](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/simon-swanson/32/24635_2.png) [@simon-swanson](https://discuss.circleci.com/u/simon-swanson)\
**Post date:** [January 4, 2021, 7:05pm UTC](https://discuss.circleci.com/t/build-2-docker-images-on-the-same-machine/38097/2 "2021-01-04T19:05:03Z")

</div>

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

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

```

in the end. Notice how the tag is constructed in the [orb source](https://github.com/CircleCI-Public/aws-ecr-orb/blob/master/src/commands/build-image.yml#L125).

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

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

```
