These tips will be useful for developers who are already familiar with docker and understand the fundamental principle behind it. In my opinion, these are the hottest tricks for the newcomer who for some reason has not yet memorized these commands.
PLC - Peace! Love! Code!
Docker build container
docker build ./ -t "<name>:<version>" --platform=linux/amd64
SSH into a container
docker exec -it <mycontainer> bash
# or
docker exec -it <mycontainer> sh
Remove: all containers & all images
# List all containers (only IDs)
docker ps -aq
# Stop all running containers
docker stop $(docker ps -aq)
# Remove all containers
docker rm $(docker ps -aq)
# Remove all images
docker rmi $(docker images -q)
docker-compose build
# --build-arg ENV_VAR=<value> - add args
docker-compose --project-name "<name>" build \
--build-arg ENV_VAR=<value>
docker-compose up
# -d - Detached mode: Run containers in the background
docker-compose --project-name "<name>" up -d
docker-compose down
docker-compose --project-name "<name>" down
Top comments (0)