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.

  • simulate Daemon-set in kubernetes with using Deployment
  • Child components don't load when deployed Angular2 app on server with NginX
  • Can I use restarting docker instead restarting app in container?
  • How to check if docker daemon is running?
  • Testing a Node library working with Docker containers
  • Docker-Compose HAProxy missing frontend
  • Setting up logs location for Docker Logstash image
  • Docker for mac hostname insteat of IP
  • cant add cAdvisor application metric to Grafana
  • Pipe RUN's output to ENV in Dockerfile
  • Configure fig to run one container before another
  • Docker Swarm on Azure: Correct use of docker4x/logger-azure
  • 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.