2017-02-21 49 views
0

我想要一个Docker服务/ Swarm网络中的shell。具体来说,我希望能够连接到网络内部的数据库。我可以直接连接到码头群网络吗?

从管理器节点,我想:

# docker network ls 
NETWORK ID   NAME   DRIVER    SCOPE 
481c20b4039a  bridge  bridge    local 
2fhe9rtim9mz  my-network overlay    swarm 

然后

docker run -it --network my-network alpine sh 

但我得到的错误:

docker: Error response from daemon: swarm-scoped network (event-data-core-prod) is not compatible with docker create or docker run . This network can only be used by a docker service.

是否有可能以某种方式启动一个交互式会话可以连接到网络服务?

+0

如果您使用1.13那里建立一个网络,将让广告时是一个'--attachable'标志-hoc(非服务)容器加入网络。 – johnharris85

+0

有没有办法改变这个现存的网络? Docs似乎没有暗示它。我不想停止整个网络来编辑这个配置值。 https://docs.docker.com/engine/reference/commandline/network/ – Joe

回答

2

由于泊坞引擎v1.13(像已经由johnharris85提到的)它is可能用于非服务容器附着到创建网络时使用--attachable命令行参数群模式覆盖网络:

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

关于你的后续问题:

Is there a way to change this for an extant network?

是,也不是,就像我已经描述d在another question你可以使用docker service update特点:

要更新一个已经运行的搬运工服务:

  1. 创建一个可连接覆盖网络:

    docker network create --driver overlay --attachable my-attachable-overlay-network 
    
  2. 删除与网络堆栈禁用的“可连接”覆盖网络(在本示例中称为:my-non-attachable-overlay-network):

    docker service update --network-rm my-non-attachable-overlay-network myservice 
    
  3. 添加网络堆栈与启用“附着”覆盖网络:

    docker service update --network-add my-attachable-overlay-network myservice 
    
相关问题