# Docker cache not working for more than a single docker build command in a build

**URL:** <https://discuss.circleci.com/t/docker-cache-not-working-for-more-than-a-single-docker-build-command-in-a-build/31246>\
**Category:** Build Environment\
**Tags:** docker\
**Created:** [July 8, 2019, 8:47am UTC](https://discuss.circleci.com/t/docker-cache-not-working-for-more-than-a-single-docker-build-command-in-a-build/31246 "2019-07-08T08:47:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiram](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/amiram/32/13405_2.png) [@amiram](https://discuss.circleci.com/u/amiram)\
**Post date:** [July 8, 2019, 8:47am UTC](https://discuss.circleci.com/t/docker-cache-not-working-for-more-than-a-single-docker-build-command-in-a-build/31246/1 "2019-07-08T08:47:20Z")

</div>

Hi,  
My build is building two different docker images.  
The repo structure is:

Root

- A  
dockerfile
- B  
dockerfile

The config.yml starts with the cache command:

```
- setup_remote_docker:
       docker_layer_caching: true

```

Then I have two steps like:

```
- run:
          name: Build A
          command: docker build -t brand/A:$CIRCLE_BUILD_NUM .
          working_directory: A
- run:
          name: Build B
          command: docker build -t brand/B:$CIRCLE_BUILD_NUM .
          working_directory: B

```

In each docker file I have these steps:

```
COPY package.json .
COPY yarn.lock .

RUN yarn

COPY . .

RUN yarn run build-ci

```

Now if I run the build without any change in code, all docker command use the cache. If I run the build only with changes in directory B, A commands are using the cache but B commands are not (after the change was copied) which is expected.  
The problem is that if I run the build after a change only in directory A, and A commands don’t use the cache, B commands also don’t use the cache although there was no change inside B folder.

Any idea why?  
Thanks
