Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A few handy Docker commands
# Delete all stopped containers
docker rm $(docker ps -a -q)
# Remove unused, dangling images
docker rmi $(docker images -q -f dangling=true)
# Remove all but X images with a specific name (old image cleanup),
# in this case, we leave the 2 newest images.
$(docker images | grep my-docker-image | tail -n+3 | awk '{ print $1":"$2; }')
# Specific commands for Elastic Beanstalk
EB_CURRENT_CONTAINER=$(docker ps | grep current-app | awk '{ print $1}')
# Show logs for the current running deployment
docker logs $EB_CURRENT_CONTAINER
# Jump into the current running container. This gives you an
# interactive shell within the same container as the currently
# running 'current-app'. The command will fail if no container
# with that name is currently running.
docker exec -it $EB_CURRENT_CONTAINER /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment