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.

  • Docker - Mac OSX Ubuntu fails on apt-get update
  • Why is git clone failing when I build an image from a dockerfile?
  • Is there a simple way to configure Docker Private Registry 2.0 with LDAP?
  • Unable to access web application in Docker container via container's ip and exposed port over http
  • Copy directory before update and import after compile.
  • How does one specify a particular cipher suite for a nginx docker instance?
  • 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.

  • Could not run Calabash-android on docker
  • Run two processes in a single docker container or two containers connecting to the same DB?
  • How to rate-limit upload from docker container?
  • Bash Command Templating For Docker
  • Unable to ping docker container
  • Docker Compose Rails Tutorial: Where did the files go?
  • 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.