How to run containers in a swarm with filters using the Docker Remote API?

I want to run containers in my swarm with some filters using the Docker Remote API. E.g. I would like to use the REST API to do the same thing as this command:

$ docker run -d --name logger -e affinity:container==front logger

I know that the Swarm API is mostly compatible with the Docker Remote API and I read the Remote API documentation but I can’t find which parameters I have to use to create an equivalent command with the REST API.

  • Log file configuration using Crate.IO database docker image
  • Environment variables from env fiile in entrypoint in docker-compose.yml
  • Increment command timeout in EBS from the -AWS
  • My docker was stuck by down whalesay, what should I do?
  • Protractor in a Docker container - Wait for full page to load
  • Flock command - “waiting” threads
  • Docker Compose in Bluemix KeyError Message
  • mongodb replica set master “stateStr” : “REMOVED”
  • Where can I access docker file system on windows
  • Docker build error with vue-cli Webpack boilerplate
  • How to trigger a Liveness Probe failure in kubernetes
  • Docker for non-code deployments?
  • One Solution collect form web for “How to run containers in a swarm with filters using the Docker Remote API?”

    As the -e flag states, affinity:container==front is an environment variable thus the JSON parameter Env has to be used. In this example the parameter is:

    { "Env" = "affinity:container==front"}
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.