title: Cannot use existing network in Compose: ERROR: Network declared as external, but could not be found
body: <p>I'm trying to create a service that must join the existing stack, so I force the compose to use the same network.</p>
  <p>Surely, my network is persists</p>
  <pre><code> docker network ls
     NETWORK ID          NAME                             DRIVER              SCOPE
     oiaxfyeil72z        ELK_default                      overlay             swarm
     okhs1e1wu73y        ELK_elk                          overlay             swarm
  </code></pre>
  <p>My docker-compose.yml</p>
  <pre><code>version: '3.3'
  services: 
    logstash:
      image: docker.elastic.co/logstash/logstash-oss:7.5.1
      ports:
        - &quot;5000:5000&quot;
        - &quot;9600:9600&quot;
      volumes:
        - '/share/elk/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro'
        - '/share/elk/logstash/pipeline/:/usr/share/logstash/pipeline/:ro'
      environment:
        LS_JAVA_OPTS: &quot;-Xmx512m -Xms256m&quot;
      networks:
        - elk
      deploy:
        mode: replicated
        replicas: 1
  networks:
    elk:
      external: 
         name: ELK_elk
  </code></pre>
  <p>the other services was created with</p>
  <pre><code>version: '3.3'
  services:
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
      ports:
        - &quot;9200:9200&quot;
        - &quot;9300:9300&quot;
      volumes:
        - '/share/elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro'
      environment:
        ES_JAVA_OPTS: &quot;-Xmx512m -Xms256m&quot;
        ELASTIC_PASSWORD: changeme
        discovery.type: single-node
      networks:
        - elk
      deploy:
        mode: replicated
        replicas: 1
        
    kibana:
      image: docker.elastic.co/kibana/kibana:7.5.1
      ports:
        - &quot;5601:5601&quot;
      volumes:
        - '/share/elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml:ro'
      networks:
        - elk
      deploy:
        mode: replicated
        replicas: 1
  
  networks:
    elk:
      driver: overlay
  </code></pre>
  <p>check with docker stack services</p>
  <pre><code>docker stack services ELK
  ID                  NAME                MODE                REPLICAS            IMAGE                                                 PORTS
  c0rux6mdvzq3        ELK_kibana          replicated          1/1                 docker.elastic.co/kibana/kibana:7.5.1                 *:5601-&gt;5601/tcp
  j824fd0blxdp        ELK_elasticsearch   replicated          1/1                 docker.elastic.co/elasticsearch/elasticsearch:7.5.1   *:9200-&gt;9200/tcp, *:9300-&gt;9300/tcp
  </code></pre>
  <p>Then trying to bring the service up with <code>docker-compose up -d</code>. The service doesn't create but produce the error</p>
  <pre><code>docker-compose up -d
  WARNING: Some services (logstash) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
  WARNING: The Docker Engine you're using is running in swarm mode.
  
  Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.
  
  To deploy your application across the swarm, use `docker stack deploy`.
  
  Removing tmp_logstash_1
  Recreating bbf503fc3eaa_tmp_logstash_1 ... error
  
  ERROR: for bbf503fc3eaa_tmp_logstash_1  Cannot start service logstash: Could not attach to network ELK_elk: rpc error: code = PermissionDenied desc = network ELK_elk not manually attachable
  
  ERROR: for logstash  Cannot start service logstash: Could not attach to network ELK_elk: rpc error: code = PermissionDenied desc = network ELK_elk not manually attachable
  ERROR: Encountered errors while bringing up the project.
  </code></pre>