Here's a collection of useful commands for using docker within DataMade's stack.
Sometimes docker behaves weirdly and fails to build / restarts suddenly. This is typically because it ran out of hard drive space.
docker volume rm $(docker volume ls -qf dangling=true)
List dangling volumes:
docker volume ls -qf dangling=true
List all volumes:
docker volume ls
Remove <none>
images that sometimes get generated when a Docker build is interrupted and then hang around:
docker rmi $(docker images | grep '^<none>' | awk '{print $3}')
Connect to the container's bash session:
docker-compose run --rm app bash
Connect to the Django shell:
docker-compose run --rm app python manage.py shell
List all of the running containers:
docker ps
Kill a specific container:
docker kill <pid> # you got the PID from the docker ps command
Remove all volumes from your machine (this one will take a while and will require you to rebuild any image you want to use again):
docker system prune --all
Build without using the cache:
docker-compose build --no-cache
Add a new npm package:
docker-compose run --rm app npm install <package-name>
List all the containers (not only the running ones):
docker ps -a
Debug your image:
docker logs <my-container-image>
Attach to a pdb session. First get the process id (via docker ps
) and then:
docker attach 833ec224bdeb