By using AWS re:Post, you agree to the Terms of Use
/One-shot docker containers using Docker compose/

One-shot docker containers using Docker compose


I have a distributed application set up in a Docker environment. Currently, I am able to run the application in my local machine, using docker-compose to start both the manager and the workers. The docker-compose.yaml file looks similar to this:

version: "3"
    image: ${IMAGE}
    command: binary start-manager --port 1234
    image: ${IMAGE}
    command: binary start-worker --address manager --port 1234
      - manager
      replicas: 2

This application is meant to run once, and when the manager finishes, it stops the workers and then stops itself. Currently, I am able to run the application in AWS using a docker context (I followed this).

The main problem I have is that once it is run using docker --context myContext compose up, it creates ECS services that, once the specific task finishes, it creates a new task; so I have to monitor the containers and run docker --context myContext compose down when it finishes.

I found that service.deploy.restart_policy is not implemented, so my question is: can I run this application once, and ensure that no tasks are spawned again once the manager service stops?



1 Answers

As you mentioned, the Docker tooling will create ECS Services which are designed to keep your containers always running (like a web server, for example). In order to achieve your outcome (run the manager/workers to completion then stop), you'll want to register a Task Definition that includes both containers, then use the ECS RunTask API to run a single instance of your Task Definition.

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions