简体   繁体   中英

docker swarm compose constraints

I have one swarm manager and two swarm nodes and I would like to start a container based on some labels I defined on the docker deamon. This is the command I tried out:

docker -H :2376 run -e constraint:node==docker2 image/restservice
docker: Error response from daemon: Unable to find a node that satisfies the following conditions 
[available container slots]
[node==docker2].

here is what I get if I run docker info with swarm.

Containers: 13
 Running: 4
 Paused: 0
 Stopped: 9
Images: 54
Server Version: swarm/1.2.3
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 2
 docker-node-1: 192.168.56.104:2375
  └ ID: I32N:D2XQ:I2FL:WDDR:YQ32:BJ62:XRWJ:7TDR:XD74:IH5M:Y2W2:4PD6
  └ Status: Healthy
  └ Containers: 7
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 2.061 GiB
  └ Labels: executiondriver=, kernelversion=3.16.0-4-amd64, node=docker2, operatingsystem=Debian GNU/Linux 8 (jessie), storagedriver=aufs
  └ UpdatedAt: 2016-08-16T18:47:05Z
  └ ServerVersion: 1.11.1
 docker-node-2: 192.168.56.106:2375
  └ ID: 6VAY:KCMX:JTTG:SQXW:BFMK:MPNJ:AWEL:F3LT:FCXI:SQRO:ORDK:MOHY
  └ Status: Healthy
  └ Containers: 6
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 2.061 GiB
  └ Labels: executiondriver=, kernelversion=3.16.0-4-amd64, node=docker3, operatingsystem=Debian GNU/Linux 8 (jessie), storagedriver=aufs
  └ UpdatedAt: 2016-08-16T18:47:19Z
  └ ServerVersion: 1.11.1
Plugins: 
 Volume: 
 Network: 
Kernel Version: 3.16.0-4-amd64
Operating System: linux
Architecture: amd64
CPUs: 2
Total Memory: 4.123 GiB
Name: bdf49c666300
Docker Root Dir: 
Debug mode (client): false
Debug mode (server): false
WARNING: No kernel memory limit support

Did I miss someting?

On the swarm mode first of all you don't run containers per se. You run services which will run containers. And your constraints are not given to service creation in the right manner. I think the best way to learn the proper way to do it is via the docker service create cli reference . https://docs.docker.com/engine/reference/commandline/service_create/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM