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

后端 未结 2 1825
误落风尘
误落风尘 2021-02-12 09:32

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

相关标签:
2条回答
  • 2021-02-12 09:47

    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
      
    0 讨论(0)
  • 2021-02-12 10:00

    By default, overlay networks created with the new swarm mode cannot be used with containers not run from swarm. Version 1.13 allows you to toggle this setting, so make sure you've upgraded. You must create the network with the attachable flag. I also couldn't get this to work on a swarm worker, the node needed to be promoted to a swarm manager.

    0 讨论(0)
提交回复
热议问题