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.

  • How mount subdirectory in mounted directory in Docker?
  • apt-get update' returned a non-zero code: 100
  • Docker native Windows support?
  • Running Docker Containers on Docker Swarm using Marathon?
  • How can I reduce the size of Docker images
  • can I mount subdir of volume in docker run command
  • Scheduling Docker containers to Cluster: Swarm or CoreOS?
  • How can JVMs running inside Bluemix container groups be monitored?
  • Gracefully stop Phusion Passenger running on apache
  • How do I compile python for Alpine?
  • How many docker containers can i run simultaneously on single host?
  • ERROR: repository x not found: does not exist or no pull access
  • 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.