Connect to shell of containerized application like you were used to before Docker.
- (Prereq) Install
awscli
(https://aws.amazon.com/cli/) andjq
(https://stedolan.github.io/jq/) - Make sure you have
aws
configured with stored authentication - Download
bin
folder from this repository and copy content to your/usr/local/bin
- Add path to your ECS PEM file to
ECS_PEM_FILE
environment variable
All commands expect your aws
command is configured with default AWS region. Also majority of commands expect ECS_PEM_FILE
ENV variable to be pointing to PEM file for SSH access to ECS cluster hosts.
Start new ECS task with overridden CMD to sleep 30m
and connect to its shell. Stops tasks after shell is exited.
ecs-run-shell cluster-name task-definition-name[:version]
This is useful to run your app framework console (like rails console
) within environment and with ENV variables of your ECS service or task while not risking failure of already running containers.
If task definition defines more than 1 container, all of containers are started but it connects you to first one.
Connect to running container of specific service.
ecs-connect cluster-name service-name
This is useful to investigate inner state of processes inside container or run processes with available environment variables from task definition.
If your service is running more than 1 task, first task provided by aws
interface is used to connect to.
If your task has more than 1 containers, first container is taken.
Warning: Be aware that you are inside container that runs the main process already. Starting heavy processes may cause the whole container will run out of memory and be killed.