Quick Docker Compose commands for ECS
I’m pretty new to Dockering in the wild, and I’m trying to use the new ECS integration to push all of my tiny app to the cloud.
This is a list of tiny helpers I wrote.
Logout of all registries
cat ~/.docker/config.json | jq '.auths | keys[]' -r | xargs -rn1 docker logout
Basically get existing sessions from the confing file, then logout on each.
Login to my AWS ECRs
PROFILE=best-profile
REGION=us-east-1
REPOSITORIES="$(aws ecr --region "$REGION" --profile "$PROFILE" describe-repositories | jq '.repositories[].repositoryUri' -r | perl -pe 's|(amazonaws.com)/.*|\1|' | sort | uniq)"
PASS="$(aws ecr get-login-password --region "$REGION" --profile "$PROFILE")"
echo "$REPOSITORIES" | xargs -I {} docker login --username AWS --password "$PASS" {}
Get all repositories, for each get the registry and login to each.
Deploy everything
Create context:
docker-compose-cli context create ecs best-context
Deploy stuff:
docker compose build
docker compose push
docker-compose-cli --context best-context compose up --build