Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"network not manually attachable" when running one-off command against docker swarm network

I'm trying to run a one-off command to initialise a database schema in a new docker swarm which is deployed with 1.13's new support for docker-compose files.

The swarm has the following network:

$ docker network ls NETWORK ID          NAME                DRIVER              SCOPE ... b7dptlu8zyqa        vme_internal         overlay             swarm ... 

defined in the docker-compose.yml file as:

networks:     internal: 

The command I run is

docker run --rm --network vme_internal app:0.1 db upgrade 

with the extra vme_ prefix coming from the name that I gave the stack when deploying. Now when I run the above command, I get:

docker: Error response from daemon: Could not attach to network vme_internal: rpc error: code = 7 desc = network vme_internal not manually attachable. 

How do I make the network attachable?

I couldn't find any specific info about attachable in Docker networking and tried adding an attribute attachable to the network definition without success.

like image 322
sas Avatar asked Jan 25 '17 09:01

sas


People also ask

What networks are affected when you join a Docker host to an existing Swarm?

When you initialize a swarm or join a Docker host to an existing swarm, two new networks are created on that Docker host: an overlay network called ingress , which handles the control and data traffic related to swarm services.

Which network driver should be used with Docker Swarm?

The overlay driver creates a distributed network that can span multiple Docker hosts, and therefore is the preferred driver for managing container communication within a multi-host cluster. overlay is the default driver for Docker swarm services.

What is overlay network in Docker Swarm?

The docker_gwbridge is a virtual bridge that connects the overlay networks (including the ingress network) to an individual Docker daemon's physical network. Docker creates it automatically when you initialize a swarm or join a Docker host to a swarm, but it is not a Docker device.

What is the Docker command to add a network to a service?

Use the --network-add or --network-rm flags to add or remove a network for a service. You can use the short or long syntax discussed in the docker service create reference.


1 Answers

Using composer

Since composer v3.2 it is possible to configure the attachable property through the composer file using the keyword attachable like:

networks:   mynet1:     driver: overlay     attachable: true 

Using docker network create

Since Docker Engine API v1.25 it is possible to create a network and make it attachable using the --attachable parameter like:

docker network create --driver overlay --attachable my-overlay-network 

To update an already running docker service:

  1. Create an attachable overlay network:

    docker network create --driver overlay --attachable my-attachable-overlay-network 
  2. Remove the network stack with a disabled "attachable" overlay network (in this example called: my-non-attachable-overlay-network):

    docker service update --network-rm my-non-attachable-overlay-network myservice 
  3. Add the network stack with an enabled "attachable" overlay network:

    docker service update --network-add my-attachable-overlay-network myservice 
like image 115
Murmel Avatar answered Sep 30 '22 08:09

Murmel