Reputation: 768
this is my compose.yml:
exp_db:
image: <img>
cpu_shares: 100
mem_limit: 362144000
volumes_from:
- exp_db_data
exp_db_data:
image: <img>
cpu_shares: 100
mem_limit: 362144000
exp_db is supposed to start up postgres and exp_db_data is volume for postgres data.
When I want to run the task with:
ecs-cli compose --file compose.yml up
The task is stopped (exit 0). When I inspect the reason why it stopped, it says that Essential container in task exited. I'm not sure if the volume container is supposed to not exit. When using docker-compose on my local all works as expected. So what am I doing wrong? I'm fairly new to docker, so I'm probably missing something or misunderstanding some fundamentals.
Thanks
Upvotes: 4
Views: 1021
Reputation: 60104
This has happened when you run two or more service in the same task definition, you can change that behaviour but there should be one container that should keep your service up and running.
For example, If you have two containers, suppose
You think Container B is not required for A, if B is down you do not want to restart A, all you need to set
"essential": false,
in the B
container task definition.
This work for me with ECS agent 1.36.2
.
Upvotes: 0
Reputation: 1504
I think this is what it was happening here: If the essential parameter of a container is marked as true in task definition, and that container fails or stops for any reason, all other containers that are part of the task are stopped. If the essential parameter of a container is marked as false, then its failure does not affect the rest of the containers in a task. If this parameter is omitted, a container is assumed to be essential. [1]
All tasks must have at least one essential container.
If you have an application that is composed of multiple containers, you should group containers that are used for a common purpose into components, and separate the different components into multiple task definitions. [2]
[1] https://docs.aws.amazon.com/AmazonECS/latest/userguide/task_definition_parameters.html
[2] https://docs.aws.amazon.com/AmazonECS/latest/userguide/application_architecture.html
Upvotes: 1