Would Docker swarm assist me with managing containers with specific environment variables?

Essentially I need to be able to start container with a specific environment variable (an account ID). And I need to run a multiple number of such containers (each with different account IDs).

I’d need to be able to start additional containers, without having to stop the existing containers. I’d also need to be able to stop specific containers. So kind of like a dynamic docker-compose config.

  • Keep Docker running when shell script exits
  • How to change “remote process types” for Heroku deploy with Docker
  • How can i add a command to the meteor mupx start script?
  • Understanding Docker container resource usage
  • how to set docker container hostname/IP permanently
  • Copy files between docker machines
  • Is Docker swarm something that could assist with the above functionality? Are there other tools (Kubernetes maybe?) alternatively?

    Otherwise, if I handled this with the docker-cli, I would start the containers using docker run passing the relevant environment variable, I’d need to make sure that a container does not already exist with this environment variable and restart the container if it exists.

  • building docker 0.7.2 from sources on Ubuntu 12.04
  • Sequel Pro with Mysql in Docker
  • How to bind a shared directory from container to host in Docker
  • Docker setting up
  • Node-inspector in docker does not load sources
  • Why might Docker Compose restart be rendering container output an increasing number of times?
  • One Solution collect form web for “Would Docker swarm assist me with managing containers with specific environment variables?”

    You can create a new service for each account ID and pass that information as an environment variable. Here is an example:

    docker service create --name service-for-account-123 --env accountId=123 imagename:latest 
    

    To stop the containers of this service you can scale it to zero, like this:

    docker service scale service-for-account-123=0
    

    To remove all containers you must remove the service:

    docker service rm service-for-account-123
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.