Docker#
Commands#
build:
docker build . -t <tag_name>
connect to a container:
docker exec -it <container_name> bash
delete
delete all volumes:
docker volume rm $(docker volume ls -q)
- docker volume rm - docker volume lsdelete all:
docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q)
list containers - docker ps
list running containers:
docker ps
list all containers:
docker ps -a
prune
prune all images:
docker image prune --all
system:
docker system prune
system with images:
docker system prune --all
Dockerfile#
set variables:
ARG variable=value
use variables example:
WORKDIR /home/$variable
optimization tools and how-tos:
https://www.fromlatest.io/
https://www.augmentedmind.de/2022/02/06/optimize-docker-image-size/
https://www.ecloudcontrol.com/best-practices-to-reduce-docker-images-size/
docker-compose#
https://docs.docker.com/compose/
store config in
docker-compose.yml
by defautstart (build images before starting containers):
docker-compose up --build
- docker-compose upadd
-d
for detached mode
stop
stop and remove containers:
docker-compose down
- docker-compose downstop and remove containers and volumes:
docker-compose down -v
- docker-compose down
validate and view compose file:
docker-compose config
- docker-compose config
Docker on Mac#
install docker with
brew install docker
use colima: https://github.com/abiosoft/colima