<p>Because of increasing build time of our pipeline, we have tried several things to improve it. One step which was taking quite some time was the docker images push step which was running sequentially. Being 12 images, this step was taking 12-14 minutes and we decided trying to push the images in parallel (under the considerate that this will take the time from 12-14 to 2-4 minutes).</p>

<p>Tried multiple steps under a publish images stage, but it fails.</p>

<pre><code>- name: Publish images
  steps:
    - publishImageConfig:
        dockerfilePath: ./frontend/deployment/Dockerfile
        buildContext: ./frontend
        tag: registry.remote.com/remote/frontend-${CICD_EXECUTION_ID}
        pushRemote: true
        registry: registry.remote.com
    - publishImageConfig:
        dockerfilePath: ./gateway/backend/src/Dockerfile
        buildContext: ./gateway/backend
        tag: registry.remote.com/remote/backend-${CICD_EXECUTION_ID}
        pushRemote: true
        registry: registry.remote.com
    [...]
</code></pre>

<p>One image is pushed, but all the rest fail with <code>Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?</code></p>

<p>I've also tried increasing the <code>--max-concurrent-uploads</code> from <code>/etc/docker/daemon.json</code> without any success.</p>

<p>Docker's <code>/var/lib/docker</code> can only be managed by a single daemon. If you want to publish more than one there is a workaround for that. Try something like this:</p>

<pre><code>stages:
- name: Publish images_1
  steps:
    - publishImageConfig:
        dockerfilePath: ./frontend/deployment/Dockerfile
        buildContext: ./frontend
        tag: registry.remote.com/remote/frontend-${CICD_EXECUTION_ID}
        pushRemote: true
        registry: registry.remote.com
- name: Publish images_2
  steps:
    - publishImageConfig:
        dockerfilePath: ./gateway/backend/src/Dockerfile
        buildContext: ./gateway/backend
        tag: registry.remote.com/remote/backend-${CICD_EXECUTION_ID}
        pushRemote: true
        registry: registry.remote.com
      env:
        PLUGIN_STORAGE_PATH: /var/lib/docker_2
    [...]
</code></pre>

<p>This bug was already reported in <a href="https://github.com/rancher/rancher/issues/16624" rel="nofollow noreferrer">this thread</a>, you can find more info there.
Issue was supposed to be fixed in Rancher <code>v2.2</code> but some people still experience this in <code>v2.3</code>.
However, the workaround is still valid.</p>

<p>I am posting this answer as a community wiki because the fix was not my original idea.</p>

<p>Please let me know if that helped.</p>
