# Sharing build using docker plugin

**URL:** <https://forum.buildkite.community/t/sharing-build-using-docker-plugin/1273>\
**Category:** General\
**Created:** [October 8, 2020, 12:57pm UTC](https://forum.buildkite.community/t/sharing-build-using-docker-plugin/1273 "2020-10-08T12:57:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unexpectedsalmon](https://avatars.discourse-cdn.com/v4/letter/u/e99b99/32.png) [@unexpectedsalmon](https://forum.buildkite.community/u/unexpectedsalmon)\
**Post date:** [October 8, 2020, 12:57pm UTC](https://forum.buildkite.community/t/sharing-build-using-docker-plugin/1273/1 "2020-10-08T12:57:18Z")

</div>

Hi

I have the following yml file

```auto
steps:
  - label: "build"
    command:
      - "yarn install"
    agents:
      queue: "v1"
    plugins:
      - docker#v3.5.0:
          mount-ssh-agent: true
          image: "cypress/browsers:node10.16.0-chrome77"

  - label: "compile scripts"
    command:
      - "yarn compile-scripts"
    agents:
      queue: "v1"
    plugins:
      - docker#v3.5.0:
          mount-ssh-agent: true
          image: "cypress/browsers:node10.16.0-chrome77"

  ... more steps 

```

I would like to use a single build step followed other steps such as unit tests, automation tests, etc. We’re using the docker plugin which is mounting the build agent. Is this the correct way to share the build between steps or is there a mount/volume/meta data approach I should be taking?

---

<div class="post-metadata">

**Author:** ![shevaun](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/shevaun/32/859_2.png) [@shevaun](https://forum.buildkite.community/u/shevaun)\
**Post date:** [October 9, 2020, 2:54am UTC](https://forum.buildkite.community/t/sharing-build-using-docker-plugin/1273/2 "2020-10-09T02:54:05Z")

</div>

Hey @unexpectedsalmon,

I see you’ve also sent an email to [support@buildkite.com](mailto:support@buildkite.com).  
I’ve sent you a reply via email – please let me know if it helps or not!

Regards,  
Shevaun

---

<div class="post-metadata">

**Author:** ![smoreno-allurion](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@smoreno-allurion](https://forum.buildkite.community/u/smoreno-allurion)\
**Post date:** [May 29, 2023, 1:06pm UTC](https://forum.buildkite.community/t/sharing-build-using-docker-plugin/1273/4 "2023-05-29T13:06:19Z")

</div>

Hi,  
Each step runs in its own “environment”, isolated from the rest, that kind of limit your options. I’ve had the same issue and depending on the requirements of the pipeline these are the 2 options best worked for me:

1. Running both commands on the same step. In you case that’d be running `yarn install` and then `yarn compile-scripts` on the same step/docker container. It’s clean, and fast. You won’t be able to “see” them in separated steps, but you do can separate the log sections with something like `echo "~~~ Yarn install` commands before each of them. (Check the docs on how to manage the log output: [Managing Log Out](https://buildkite.com/docs/pipelines/managing-log-output))

2. The second option is to use the [Cache plugin](https://github.com/nienbo/cache-buildkite-plugin) to save the installed dependencies and then share/download them again on the following step. useful when many subsequent steps need the dependencies.

Hope this helps 🙂
