Docker1.12 swarm模式下让容器在指定节点运行
2016-09-09 10:06
881 查看
使用docker service create创建容器时默认会使用调度机制选择集群内的一个节点运行容器
如果希望创建的容器运行在指定的节点上可通过--constraint参数通过label来在指定的节点
第一步,在节点启动的docker daemon加上--label
命令参数说明:
例如我的配置 /etc/systemd/system/docker.service.d/docker.conf
constraint后面的参数除了可以用==还可以用!=
之前的版本有支持表达式匹配,现在这个好像用不了,难道是打开方式不对?
如果希望创建的容器运行在指定的节点上可通过--constraint参数通过label来在指定的节点
第一步,在节点启动的docker daemon加上--label
命令参数说明:
[root@centos-minion2 ~]# dockerd --help| grep label --label=[] Set key=value labels to the daemon
例如我的配置 /etc/systemd/system/docker.service.d/docker.conf
[Service] ExecStart= ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock --insecure-registry 192.168.209.0/24 --label hostname=minion2然后重启服务
[root@centos-minion2 ~]# systemctl daemon-reload [root@centos-minion2 ~]# systemctl restart docker在MANAGER 查看label
[root@centos-master ~]# docker node inspect -f '``.`Description`.`Engine`.`Labels`' centos-minion2 map[hostname:minion2]第二步,创建service 指定在centos-minion2 这个节点上运行容器
[root@centos-master ~]# docker service create --name web --replicas 4 --constraint engine.labels.hostname==minion2 nginx
constraint后面的参数除了可以用==还可以用!=
之前的版本有支持表达式匹配,现在这个好像用不了,难道是打开方式不对?
相关文章推荐
- docker swarm如何在指定的node上运行指定的容器
- 立足Docker运行MySQL:多主机网络下Docker Swarm模式的容器管理
- docker swarm如何在指定节点运行service
- docker swarm模式指定宿主机运行服务pending问题
- 在 Docker 中运行 MySQL:多主机网络下 Docker Swarm 模式的容器管理
- 轻松安装docker并运行docker swarm模式
- docker swarm model模式下的每个容器夸主机互通
- 多主机网络下 Docker Swarm 模式的容器管理
- Docker - 运行 containers 使用在 swarm 模式下创建的 overlay 模式的 network
- 多主机网络下 Docker Swarm 模式的容器管理
- Docker - 运行 containers 使用在 swarm 模式下创建的 overlay 模式的 network
- Docker的安装方法及运行Docker Swarm模式的使用
- Docker1.12版本swarm模式下的网络模型
- 多主机网络下 Docker Swarm 模式的容器管理
- Docker1.12版本swarm模式下的网络模型
- 在docker宿主机上查找指定容器内运行的所有进程的PID
- Docker 1.12 swarm模式下遇到的各种问题
- 安装docker并运行docker swarm模式
- 多主机网络下 Docker Swarm 模式的容器管理