Skip to content

Instantly share code, notes, and snippets.

@chiedo
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiedo/e3ff751fed1b641c2ee9 to your computer and use it in GitHub Desktop.
Save chiedo/e3ff751fed1b641c2ee9 to your computer and use it in GitHub Desktop.
Have your docker container start wait for your to enter it with the command it provides.
# Tested on Docker 1.5
# make the following the command for docker-compose.yml
# You will obviously first need to do a chmod +x on docker-compose-web-up.sh and add it to your docker container.
# command: bash docker-compose-web-up.sh
# See https://github.com/chiedojohn/django-starter for implementation example.
# Wait a couple seconds to make sure this output is the last thing in the console
sleep 2
# Get the container ID
CONTAINER_ID="$(cat /proc/self/cgroup | grep "docker" | sed s/\\//\\n/g | tail -1)"
# Print out the command needed to enter the docker web container
printf "\nTo enter your Docker web container, run the below:\n------------\ndocker exec -it ${CONTAINER_ID} bash\n"
# The below is a hackish way to make the web container run indefinitely until stopped
tail -f /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment