title: Docker compose recreates images on CircleCI even though images are up-to-date
body: <p>We have services as docker images that get built, pushed to Dockerhub, and deployed on every new commit by CircleCI. Recently I made changes to not build images if there are no changes, and also the containers should not be recreated/restarted.</p>
  <p>When now a new change is pushed, however, the deploy step recreates the images even though the images are &quot;up-to-date&quot;. Normally, when images are up-to-date and no <code>--force-recreate</code> flag was passed, the containers should not be recreated.</p>
  <p>I wasn't able to reproduce the issue either. Everytime I run the deploy script on the server or by running the deploy CI job again, I get <code>&lt;image&gt; up-to-date</code> and no recreating. With a new commit, images get recreated.</p>
  <p>What could be the reason for Docker Compose to recreate images even though images are up-to-date?</p>
  <p>Output with new commit on CI:</p>
  <pre><code>Total reclaimed space: 0B
  Pulling ui         ... pulling from ethereum/source-verify
  Pulling ipfs       ... pulling from ethereum/source-verify
  Pulling repository ... pulling from ethereum/source-verify
  Pulling ui         ... digest: sha256:e22696dbf450784262...
  Pulling ui         ... status: image is up to date for e...
  Pulling ipfs       ... digest: sha256:8b2f5b048da2928b73...
  Pulling ipfs       ... status: image is up to date for e...
  Pulling repository ... digest: sha256:c269996c2802528b86...
  Pulling repository ... status: image is up to date for e...
  Pulling ui         ... done
  Pulling s3sync     ... pulling from ethereum/source-verify
  Pulling ipfs       ... done
  Pulling repository ... done
  Pulling server     ... pulling from ethereum/source-verify
  Pulling s3sync     ... digest: sha256:27f35299ce74d0f7cc...
  Pulling s3sync     ... status: image is up to date for e...
  Pulling s3sync     ... done
  Pulling server     ... digest: sha256:8e62ae573dbe9c967e...
  Pulling server     ... status: image is up to date for e...
  Pulling server     ... done
  Pulling monitor    ... pulling from ethereum/source-verify
  Pulling monitor    ... digest: sha256:a647623055fc9336c3...
  Pulling monitor    ... status: image is up to date for e...
  Pulling monitor    ... done
  Recreating server-latest ... 
  Recreating repository-latest ... 
  Recreating monitor-latest    ... 
  Recreating ui-latest         ... 
  Recreating s3-latest         ... 
  Recreating ipfs-latest       ... 
  Recreating ui-latest         ... done
  Recreating monitor-latest    ... done
  Recreating server-latest     ... done
  Recreating s3-latest         ... done
  Recreating repository-latest ... done
  Recreating ipfs-latest       ... done
  CircleCI received exit code 0
  </code></pre>
  <p>on every other run I get as expected:</p>
  <pre><code>Total reclaimed space: 0B
  Pulling s3sync     ... pulling from ethereum/source-verify
  Pulling s3sync     ... digest: sha256:27f35299ce74d0f7cc...
  Pulling s3sync     ... status: image is up to date for e...
  Pulling s3sync     ... done
  Pulling ipfs       ... pulling from ethereum/source-verify
  Pulling ipfs       ... digest: sha256:8b2f5b048da2928b73...
  Pulling ipfs       ... status: image is up to date for e...
  Pulling monitor    ... pulling from ethereum/source-verify
  Pulling ipfs       ... done
  Pulling ui         ... pulling from ethereum/source-verify
  Pulling monitor    ... digest: sha256:a647623055fc9336c3...
  Pulling monitor    ... status: image is up to date for e...
  Pulling monitor    ... done
  Pulling ui         ... digest: sha256:e22696dbf450784262...
  Pulling ui         ... status: image is up to date for e...
  Pulling ui         ... done
  Pulling server     ... pulling from ethereum/source-verify
  Pulling server     ... digest: sha256:8e62ae573dbe9c967e...
  Pulling server     ... status: image is up to date for e...
  Pulling server     ... done
  Pulling repository ... pulling from ethereum/source-verify
  Pulling repository ... digest: sha256:c269996c2802528b86...
  Pulling repository ... status: image is up to date for e...
  Pulling repository ... done
  s3-latest is up-to-date
  ipfs-latest is up-to-date
  repository-latest is up-to-date
  monitor-latest is up-to-date
  ui-latest is up-to-date
  server-latest is up-to-date
  </code></pre>
  <p>This is the deploy script <strong>deploy.sh</strong></p>
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  set -e
  
  if [ &quot;$CIRCLE_BRANCH&quot; == &quot;staging&quot; ]; then 
      TAG='latest'
      REPO_PATH='/home/gather/staging/'
      SERVER='-J source-verify@komputing.org gather@10.10.42.102'
  elif [ &quot;$CIRCLE_BRANCH&quot; == &quot;master&quot; ]; then
      TAG='stable' 
      REPO_PATH='/home/sourcify/production/'
      SERVER='-J source-verify@komputing.org sourcify@10.10.42.7'
  else
      echo &quot;Invalid branch $CIRCLE_BRANCH. Check your config.yml&quot;
      exit 1
  fi
  
  curl &quot;https://raw.githubusercontent.com/ethereum/source-verify/${CIRCLE_BRANCH}/.circleci/ssh.config&quot; &gt; ~/.ssh/config
  
  ssh $SERVER &quot;\
      mkdir -p scripts &amp;&amp; curl https://raw.githubusercontent.com/ethereum/source-verify/${CIRCLE_BRANCH}/scripts/setup.sh &gt; scripts/setup.sh &amp;&amp; chmod +x scripts/setup.sh &amp;&amp; chown $USER:$USER ./scripts/setup.sh &amp;&amp; \
      REPO_PATH='${REPO_PATH}' CIRCLE_BRANCH='${CIRCLE_BRANCH}' TAG='${TAG}' ./scripts/setup.sh&quot;
  </code></pre>
  <p>which calls this <strong>setup.sh</strong>:</p>
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  set -e
  
  mkdir -p $REPO_PATH
  cd $REPO_PATH
  
  if [[ ! -d sourcify ]]; then
      git clone https://github.com/ethereum/sourcify.git sourcify
      cd sourcify
      git checkout ${CIRCLE_BRANCH}
  else
      cd sourcify
      git fetch
      git checkout ${CIRCLE_BRANCH}
      git reset --hard origin/${CIRCLE_BRANCH}
  fi
  
  if [ &quot;${TAG}&quot; == &quot;stable&quot; ]; then
      COMPOSE_COMMAND=&quot;COMPOSE_PROJECT_NAME=${TAG} docker-compose -f ipfs.yaml -f monitor.yaml -f repository.yaml -f s3.yaml -f server.yaml -f ui.yaml -f ui-legacy.yaml&quot;
  elif [ &quot;${TAG}&quot; == &quot;latest&quot; ]; then
      COMPOSE_COMMAND=&quot;COMPOSE_PROJECT_NAME=${TAG} docker-compose -f ipfs.yaml -f monitor.yaml -f repository.yaml -f s3.yaml -f server.yaml -f ui.yaml&quot;
  else
      COMPOSE_COMMAND=&quot;COMPOSE_PROJECT_NAME=${TAG} docker-compose -f ipfs.yaml -f monitor.yaml -f repository.yaml -f s3.yaml -f server.yaml -f ui.yaml -f localchain.yaml&quot;
  fi
  
  TAG=$TAG ./scripts/find_replace.sh
  source ./environments/.env
  cd environments
  docker image prune -f
  eval ${COMPOSE_COMMAND} pull
  eval COMPOSE_HTTP_TIMEOUT=1200 ${COMPOSE_COMMAND} up -d
  </code></pre>