Comments (3)
I have done this with ECS Compose-X by setting some deploy.labels which indicate family (so the two services defined in the compose file are joined in the same task definition) and you can then set an exit condition, i.e. for your init script, you could use SUCCESS
. Because of the implication here that SUCCESS
means the container runs, executes, and we expect return 0 before moving on to starting the next container, compose-x automatically understands that's not an essential container.
See https://docs.compose-x.io/syntax/compose_x/ecs.details/deploy.html#labels
There are plenty of other examples in the labs which highlight having primary containers, that have to be healthy, and others that do not.
Hope this helps :)
from compose-cli.
@JohnPreston I've been trying to figure out what you're hinting at, but I'm getting nowhere. Like @tkrotoff I too have a database migration that that exits.
With the standard docker compose (3.9) syntax, you just set the depends_on
condition to service_completed_successfully
. Are you saying that this has no effect on ECS, and there is some other mechanism that needs to be layered on top of this? i.e. so @tkrotoff's example would be changed to something like this:
services:
front:
...
back:
...
depends_on:
database-init:
condition: service_completed_successfully
deploy:
labels:
ecs.task.family: db-init
ecs.depends.condition: SUCCESS
database-init:
...
command: ['npm', 'run', 'db:init']
depends_on:
database:
condition: service_healthy
deploy:
labels:
ecs.task.family: db-init
database:
...
I can't quite figure out how this is supposed to work or what the underlying conceptual model is based on the docs you linked to.
from compose-cli.
Apologies @zuk
The docs to the tool is a different one, not the ECS docker plugin extension which sadly does not support this.
Compose-X support most of the ECS plugin x- extensions, and much more.
Taking the exemple above you should have
services:
front:
...
back:
...
depends_on:
database-init
deploy:
labels:
ecs.task.family: backend # goes to task family backend
database-init:
...
command: ['npm', 'run', 'db:init']
depends_on:
database:
condition: service_healthy
deploy:
labels:
ecs.task.family: backend # goes to task family backend
ecs.depends.condition: SUCCESS # this container starts first and must return 0 for the next one to start
database:
...
The backend task & service definition (family) will deploy both containers together in order database-init then back
command to run to create the templates / deploy to AWS ECS
ecs-compose-x init
ecs-compose-x up -f docker-compose.yaml -p my-app-stack
The database service will be created before the service "backend" though considering that you need it up and running first
If you have a DB on AWS that uses RDS you can use the x-rds module to have compose-x create ingress rules and paramete/env vars to say simplify the integration
from compose-cli.
Related Issues (20)
- se map a volume
- ECS: Is there a way to deploy on existing loadbalancers, target groups and rules? HOT 4
- Feature Request: support emptyDir volume type for Azure ACI HOT 2
- `docker compose` using ecs context does not create the correct EFS performance-mode HOT 2
- Adding "path pattern" ALB Listener Rules for ECS HOT 1
- Limited Docker CLI functionality in Azure Context (ACI)
- Linux install script fails regularly HOT 1
- ECS: Allow toggling AssignPublicIp HOT 3
- error decoding 'Ports': Invalid containerPort: 8080 HOT 1
- AssumeRoleTokenProviderNotSetError: assume role with MFA enabled, but AssumeRoleTokenProvider session option not set
- Prepare Development Server with Cloudformationt template : Prepare development server on Amazon Linux 2 (t3a.medium) for developers, enabled with `Docker`, `Docker-Compose`, `Java 11`, `Git`.
- ECS: TaskRoleARN + service.volumes -- wrong Node Kind for expected: MappingNode was ScalarNode
- ECS support broken under Linux with ""docker context create" requires exactly 1 argument." error HOT 1
- Windows named pipe error after updating Docker to latest version
- Multiple Volumes in ECS Compose pointing to same EFS Filesystem HOT 2
- Docker compose networking doesn't work any more HOT 5
- Docker Compose’s integration for ECS and ACI is retiring in November 2023. HOT 11
- incorrect warning when logging into ECR
- Error DT1001 Docker Compose's integration for ECS and ACI will be retired in November 2023. Learn more: https://docs.docker.com/go/compose-ecs-eol/ docker-compose C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 204 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-cli.