Docker (Compose) Commands that I Find Useful
Burn it All to the Ground
docker compose up
will take a long time after this, but you’re here because nothing is working anyway.
docker system prune --volumes --all
Run an interactive shell inside of a running docker container
docker ps # get the container ID / name of the service you're interested in
docker exec -it {container ID or name} bash # or maybe bin/bash if bash is not in your PATH?
Code language: PHP (php)
Run a Docker container and start an interactive shell inside of it
docker run -it {image name, like nginx:alpine} bash # or maybe bin/bash if bash is not in your PATH?
Code language: PHP (php)
Run a Docker container and start an interactive shell inside of it, bind mounting your current directory
docker run -it -v $(pwd):/{some path} {image name, like nginx:alpine} bash
Code language: JavaScript (javascript)
Build a Docker image
docker build -t {image name, like transfer-suite} . # I think this assumes the default Dockerfile name
docker build -t {image name, like transfer-suite} . -f {image name, like transfer-suite}
Code language: PHP (php)
Run a Docker image by name
docker run -p 80:80 {image name, like transfer-suite}
Leave a Reply