Skip to content

Using ECS and have multiple tasks that require the same container as a dependency? Run a given container once on an EC2 instance

Notifications You must be signed in to change notification settings

rfroetscher/run_once

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Run Once

This is an experimental proof of concept for a super simple bash script to run a given container if there are containers running on an EC2 instance aside from the ecs-agent.

Think sumologic collector, cadvisor, or others that you want to ensure are running on an instance where your other containers are running. However, you don't want to add them to your task definitions because you don't want to end up with more than one of them.

Pass the image name and the startup command of the conatiner you'd like to start if there are other containers running, like:

 docker run -v /var/run/docker.sock:/var/run/docker.sock  \
            -v $(which docker | awk '{print $NF}'):/bin/docker  \
            -it \
            run_once:latest \
            bash run_once.sh -i nginx:latest -s 'docker run -d nginx:latest'

Make sure you mount the docker binary and the docker socket as shown above so the container can communicate with the docker daemon.

About

Using ECS and have multiple tasks that require the same container as a dependency? Run a given container once on an EC2 instance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages