title: How to push a Docker Compose stack to a Docker Swarm without uploading containers to a registry?
body: <p>I've researched around before asking here, but all answers lead me to the same conclusion:</p>
  
  <ol>
  <li>Build your Docker Compose stack locally</li>
  <li>Tag and push the images to a registry (either a private or public one like Docker Hub)</li>
  <li>Push the stack to the swarm using <code>docker stack deploy --compose-file docker-compose.yml stackdemo</code></li>
  <li>From here, the stack picks up and "pulls" the images from the registry and runs the containers</li>
  </ol>
  
  <p>Is there no straightforward way to make the following (I think common sense) scenario work seamlessly?</p>
  
  <ol>
  <li>Docker swarm manager has access (SSH keys) to pull the project from Git.</li>
  <li>It periodically pulls the project and builds it "locally" using <code>docker-compose up</code></li>
  <li>When the build succeeds (containers are ready), it pushes the stack to the swarm using <code>docker stack deploy</code>, propagating the images to all worker nodes.</li>
  <li>In that way, the original "source code" is only known by the Manager Node and only it has direct access to the Git repository.</li>
  </ol>
  
  <p>Maintaining a registry (or paying for a cloud one), seems like a huge disadvantage for using Docker in Swarm Mode.</p>
  
  <p>Side note: I've tried the approach of <a href="https://docs.docker.com/engine/swarm/stack-deploy/#set-up-a-docker-registry" rel="nofollow noreferrer">deploying a registry as a service within the stack</a> and tagging + pushing the images to <code>127.0.0.1/myimage</code> but that led to a different set of problems of its own - e.g. the fact that worker nodes that do not have an instance of the Registry container running, have no access to pull the image (the registry needs to be replicated to all nodes).</p>