title: Docker stack deploy latest image works even when image is deleted
body: <p>I have a docker compose file with a container that uses the latest tag:
  <code>
    code_site:
      image: code_site:latest
      deploy:
        restart_policy:
          condition: any
      volumes:
      - ../../data_to_backup/code_site/drupal_sites:/drupal_www/sites
      - drupal_core:/drupal_www/core
      - php_fpm_socket:/var/run/php-fpm7
      networks:
      - main_net
  </code></p>
  
  <p>I have a process which will rebuild the container. I use it when I want to make changes to my site.</p>
  
  <p>I am investigating a problem where the docker stack deploy command:
  <code>
  docker stack deploy --compose-file=docker-compose.yml code_site
  </code>
  (The stack name happens to match the image name but this is a coincidence.)</p>
  
  <p>If I go through the following process:
  Delete the code_site:latest image (rmi code_site:latest)
  Rebuild a new code_site:latest image 
  Redeploy the stack</p>
  
  <p>It will bring up the OLD version of the container. This is confusing, especially as I have deleted the old version.</p>
  
  <p>I have gone further and I deleted the code_site image then I ran the stack deploy command.
  The stack deploys successfully still running the old version of the container.</p>
  
  <p>I can use the docker images command and verify that there is no container named code_site:latest so I have no idea how the stack could possibly deploy.</p>
  
  <p>Can anyone explain how the image is coming back from the dead, and what method I should use to get rid of it permanently and force docker stack to use the real image?</p>
  
  <p>Thanks
  Robert</p>
  
  <h1>Update 1</h1>
  
  <p>code_site is a locally built image
  I am running on a swarm but there is only one node in the swarm </p>