是否可以在同一台机器上启动多个docker守护程序 [英] Is it possible to start multiple docker daemons on the same machine

查看:384
本文介绍了是否可以在同一台机器上启动多个docker守护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能的话,如何配置每个守护程序-图形位置,图像位置等?

And if it is possible, how would you configure each daemon - graph location, images location, etc?

推荐答案

是,即使没有Docker Machine,也可以在单个主机上运行两个Docker守护进程。从Docker 18.09.0-ce开始,以下 dockerd 标志是如果两个守护程序使用默认值可能导致冲突的标志:

Yes, it's perfectly possible to run two Docker daemons on a single host even without Docker Machine. As of Docker 18.09.0-ce, the following dockerd flags are the ones that could cause conflicts if two daemons used the defaults:

  -b, --bridge string       Attach containers to a network bridge
      --exec-root string    Root directory for execution state files (default "/var/run/docker")
      --data-root string    Root directory of persistent Docker state (default "/var/lib/docker")
  -H, --host list           Daemon socket(s) to connect to
  -p, --pidfile string      Path to use for daemon PID file (default "/var/run/docker.pid")




  • -bridge 的默认值为 docker0 ,如果不使用默认值,则必须手动创建和配置网桥(Docker不会为您创建/管理它)。以下是更多详细信息。

    • The default for --bridge is docker0, and if you're not using the default, you must create and configure the bridge manually (Docker won't create/manage it for you). More details below.

      -exec-root 是存储容器状态的位置(默认值: / var / run / docker )。

      --exec-root is where container state is stored (default: /var/run/docker).

      -data-root 是存储图像的位置(默认值: / var / lib / docker )。

      --data-root is where images are stored (default: /var/lib/docker).

      -host 指定Docker守护程序将在何处侦听客户端连接。如果未指定,则默认为 /var/run/docker.sock

      --host specifies where the Docker daemon will listen for client connections. If unspecified, it defaults to /var/run/docker.sock.

      -pidfile 是守护进程的进程ID的存储位置(默认值: /var/run/docker.pid )。

      --pidfile is where the process ID of the daemon is stored (default: /var/run/docker.pid).

      因此,只要您的两个守护程序对这些标志使用不同的值,就可以在同一主机上运行它们。示例脚本(包括网络设置):

      So, as long as your two daemons use different values for these flags, you can run them on the same host. Example script (including network setup):

      #!/bin/sh
      ## name: altdocker.sh
      set -e -x
      
      : ${bridge=altdocker}
      : ${base=$HOME/$bridge}
      
      # Set up bridge network:
      if ! ip link show $bridge > /dev/null 2>&1
      then
         sudo ip link add name $bridge type bridge
         sudo ip addr add ${net:-"10.20.30.1/24"} dev $bridge
         sudo ip link set dev $bridge up
      fi
      
      sudo dockerd \
        --bridge=$bridge \
        --data-root=$base.data \
        --exec-root=$base.exec \
        --host=unix://$base.socket \
        --pidfile=$base.pid
      

      示例用法:

      ## in one terminal
      $ env net=10.9.8.7/24 /bin/sh altdocker.sh
      # ... log output ...
      
      ## in another terminal
      $ docker -H unix://$HOME/altdocker.socket run --rm -i -t alpine sh
      / # echo hereiam
      hereiam
      






      已更新对于从Docker 1.9.1到18.09.0-ce的更改,以防万一有人使用非常旧的版本:


      Updated for changes from Docker 1.9.1 to 18.09.0-ce, in case anyone is using a very old version:

      ┌───────────────┬─────────────┐
      │ 1.9.1         │ 18.09.0-ce  │
      ├───────────────┼─────────────┤
      │ docker daemon │ dockerd     │
      │ -g / --graph  │ --exec-root │
      └───────────────┴─────────────┘
      

      这篇关于是否可以在同一台机器上启动多个docker守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆