title: docker swarm: share a network between stacks without external
body: <p>I am deploying multiple stacks on a Docker swarm with docker compose. </p>
  
  <p>Right now I have defined a network in my proxy stack compose file:</p>
  
  <pre><code>networks:
    proxy:
      driver: overlay
  </code></pre>
  
  <p>The other stacks reference this network the following way:</p>
  
  <pre><code>networks:
    proxy_proxy:
      external: true
  </code></pre>
  
  <p>The problem with this setup is that all other stacks now depend on the proxy stack. Removing the proxy stack (e.g in order to replace/restart it) will cause an error like this:</p>
  
  <blockquote>
    <p>Failed to remove network 800w54tbh7w7clc4o8uc3y7no: Error response from daemon: rpc error: code = 9 desc = network 800w54tbh7w7clc4o8uc3y7no is in use by service 0zu489jepz586sguqrorv6j6hFailed to remove some resources from stack: proxy</p>
  </blockquote>
  
  <p>Is there a way to define a network within docker compose that is not "owned" by one stack so that if it already exists any newly deployed stack will join it and if it doesn't it will be created?</p>
  
  <p>That way there would be no dependency between the stacks.</p>