A personal cheat sheet for running local Node project in a Docker container

June 27, 2017 ยท View on GitHub

Troubleshooting

If you open a new terminal, you need the Docker environment variables again. You can set them up in the current shell by running (assuming the name default for the Docker machine)

eval "$(docker-machine env default)"

If the Docker machine becomes unresponsive with status UNKNOWN when running docker-machine ls try rebuilding it

$ docker-machine rm -y default && docker-machine create -d virtualbox default && eval $(docker-machine env)

To delete all running containers and images (use -f option to force)

#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all unused images
docker rmi $(docker images --filter dangling=true)
# Delete all images
docker rmi $(docker images -q)

To stop all running containers

IDS=$(docker ps -q)
docker stop $IDS
# or as a single command
docker stop $(docker ps -q)

If you have a container "demo" and would like to investigate it, start it in the interactive mode with a "bash" as entry

docker run -it --entrypoint bash demo