question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: set Swarm filter constraint on container create

See original GitHub issue

With Docker Swarm it is possible to set filter constraints, in order to select a Swarm Agent with certain properties. With the CLI tool this can be accomplished by specifying the “-e” parameter as described in the official documentation:

In the following example the node is selected by its name (agent1): docker run -it --rm -e constraint:node==agent1 ubuntu:trusty /bin/bash

Maybe this is already possible with docker-py, but I couldn’t figure it out.

Christoph

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dvenzacommented, Jul 18, 2016

Thank you. If someone happens to get here looking for the same thing, you have to add an environment variable with the constraint as the name and None as the value. I was trying passing an empty string and I got a weird error about not enough container slots.

On 18 July 2016 21:09:34 CEST, Christoph Jansen notifications@github.com wrote:

Hi. It’s actually easy if you know that the -e flag of the docker CLI means Environment Variable. So you can look up how to set them with docker-py and use the same parameters as with the CLI. I’m on my phone and can’t give you a Code example. Hope this helps


You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/docker/docker-py/issues/1043#issuecomment-233427577

0reactions
netoisccommented, Aug 8, 2016

Hi @Gnork , I had the same problem. I’ve used docker-py too, defining env-vars through a dict and in my case I solved this problem by setting the Key with constraint:node and the Value with =agent1. Now, when I run containers i can see the filter correctly within swarm constraints ej. "Labels": { "com.docker.swarm.constraints": "[\"node==agent1\"]"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swarm filters
Filters tell Docker Swarm scheduler which nodes to use when creating and running a container. Configure the available filters. Filters are divided into...
Read more >
Use constraints to deploy a container on a specific host #121
We need to give the ability to the user to deploy a container on a ... Should I create a separate ticket/feature request...
Read more >
Docker Swarm Mode - Features, Nodes and Filters
Docker Swarm Filters​​ There are five filters for scheduling containers in Swarm: i. Constraint – The key/value pairs associated with particular nodes is...
Read more >
Using placement constraints with Docker Swarm
Docker Swarm will automatically try and place your containers to provide maximum resiliency within the service. So, for example, if you request ......
Read more >
Networking with overlay networks
Use an overlay network for standalone containers shows how to communicate between standalone containers on different Docker daemons using an overlay network.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found