“网络不可手动连接”针对docker swarm网络运行一次性命令时 [英] "network not manually attachable" when running one-off command against docker swarm network
问题描述
我正在尝试执行一次性命令以初始化新的docker swarm中的数据库架构,该新swarm部署了1.13对docker-compose文件的新支持。
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.
该群具有以下网络:
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
...
b7dptlu8zyqa vme_internal overlay swarm
...
已定义在 docker-compose.yml
文件中:
networks:
internal:
我运行的命令是
docker run --rm --network vme_internal app:0.1 db upgrade
带有额外的 vme _
前缀,该前缀来自我在部署时给堆栈的名称。现在,当我运行以上命令时,我得到:
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.
我如何使网络可连接?
我在 Docker网络,并尝试在网络定义中添加属性 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.
推荐答案
使用作曲家
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
使用 docker network create
Using docker network create
自Docker Engine API v1.25起,就可以使用 -可附加
参数,例如:
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
< hr>
要更新已运行的docker服务:
To update an already running docker service:
-
创建可附加的覆盖图网络:
Create an attachable overlay network:
docker network create --driver overlay --attachable my-attachable-overlay-network
使用禁用的可连接覆盖网络删除网络堆栈(在本示例中为: my -non-attachable-overlay-network
):
docker service update --network-rm my-non-attachable-overlay-network myservice
添加已启用可连接的网络堆栈覆盖网络:
Add the network stack with an enabled "attachable" overlay network:
docker service update --network-add my-attachable-overlay-network myservice
这篇关于“网络不可手动连接”针对docker swarm网络运行一次性命令时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!