Skip to content

Docker

Destructive: removes all containers, images, unused networks and volumes, including database data.

Terminal window
docker rm -f $(docker ps -aq)
docker system prune -a -f
docker volume prune -a -f
Terminal window
docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -v '<none>' | sort -u | xargs -r -L1 docker pull

Useful where bind mounts are slow or break permissions, e.g. on Windows.

services:
db:
image: mysql:8.4
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- db:/var/lib/mysql
volumes:
db: {}

The server must listen on 0.0.0.0 inside the container, and the port must be published:

Terminal window
docker run --rm -it -p 127.0.0.1:8080:8080 -v "$PWD:/app" -w /app php:cli php -S 0.0.0.0:8080
Terminal window
dev() {
docker compose exec dev "${@:-bash}"
}
gander_dev() {
docker run --rm -it -p "127.0.0.1:80:80" -v "$PWD:/www" "gander/dev:${1:-8.1}" "${2:-bash}"
}

dev opens a shell in the dev service, and dev pwd runs a command there.