Skip to content

Instantly share code, notes, and snippets.

@reinaldomendes
Last active October 28, 2024 19:34
Show Gist options
  • Save reinaldomendes/b81abe18d37d88b578006d93b4ad3703 to your computer and use it in GitHub Desktop.
Save reinaldomendes/b81abe18d37d88b578006d93b4ad3703 to your computer and use it in GitHub Desktop.
Docker
# discover which container is using a volume
docker ps -a --filter volume=<VOLUME_NAME_OR_ID>
# ecs-cli
### Setup local Variables
```bash
REGION=${REGION:us-east-1}
KEY_PAIR=${KEY_PAIR:-my-cluster.pem}
OWNER=${owner:-nobody}
PROJECT=${PROJECT:-my-project}
ECS_PROFILE=${ECS_PROFILE:-my-profile}
CLUSTER_CONFIG=${CLUSTER_CONFIG:-my-cluster}
```
### create key-pair
```bash
aws ec2 create-key-pair --key-name aws-docker-cluster --query 'KeyMaterial' --output text > ~/.ssh/$CLUSTER_KEY_NAME
```
## Update account settings
```bash
aws ecs put-account-setting-default --name serviceLongArnFormat \
--value enabled \
--region $REGION
aws ecs put-account-setting-default \
--name containerInstanceLongArnFormat \
--value enabled \
--region $REGION
```
### Setup Cluster
- FARGATE
```bash
ecs-cli up --launch-type FARGATE --keypair $KEY_PAIR --size 2 --tags project=$PROJECT,owner=$OWNER
```
### ECS
- ECS
```bash
ecs-cli up \
--capability-iam \
--keypair $KEY_PAIR \
--size 2 \
--instance-type t3.small \
--tags project=aws-docker-cluster,owner=reinaldo \
--launch-type FARGATE # --ecs-profile $ECS_PROFILE --cluster-config $CLUSTER_CONFIG
```
### deploy containers
- service up
```bash
ecs-cli compose --file docker-compose.prod.yml --debug service up --deployment-max-percent 100 --deployment-min-healthy-percent 0 --create-log-groups #\ --region $REGION # --ecs-profile $ECS_PROFILE --cluster-config $CLUSTER_CONFIG
```
- scale
```bash
ecs-cli compose --file docker-compose.prod.yml --debug service up --deployment-max-percent 100 --deployment-min-healthy-percent 0 --create-log-groups #\ --region $ECS_PROFILE # --ecs-profile tutorial --cluster-config $CLUSTER_CONFIG
```
### extra options for compose service create
- --load-balancer-name OR --target-group-arn
- --health-check-grace-period
- --container-port
- --container-name
OR
- --target-groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment