meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
spickzettel:docker:docker_commands [2020/12/31 01:00:09] – Marcel Jäpel | spickzettel:docker:docker_commands [2020/12/31 01:04:13] (current) – Marcel Jäpel | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Docker Commands ====== | ||
+ | ===== Docker ===== | ||
+ | ==== Images ==== | ||
+ | === Build === | ||
+ | |||
+ | <code bash> | ||
+ | docker build -t < | ||
+ | </ | ||
+ | |||
+ | === List === | ||
+ | <code bash> | ||
+ | docker images | ||
+ | </ | ||
+ | |||
+ | === Remove === | ||
+ | <code bash> | ||
+ | docker image rm <id> | ||
+ | </ | ||
+ | |||
+ | ==== Container Start ==== | ||
+ | === Interactive Terminal in Container === | ||
+ | <code bash> | ||
+ | docker run -it -p 8080:80 --name < | ||
+ | </ | ||
+ | |||
+ | === Map port from host to container === | ||
+ | <code bash> | ||
+ | docker run -it -p 8080:80 --name < | ||
+ | </ | ||
+ | |||
+ | === Delete container after exit === | ||
+ | <code bash> | ||
+ | docker run --rm -it --name < | ||
+ | </ | ||
+ | |||
+ | === Background / Detached Container === | ||
+ | <code bash> | ||
+ | docker run -d --name < | ||
+ | </ | ||
+ | |||
+ | === Pipe data into container process === | ||
+ | <code bash> | ||
+ | echo test | docker run -i --name < | ||
+ | </ | ||
+ | |||
+ | === Bind-Mount Volume from Host === | ||
+ | <code bash> | ||
+ | docker run -it -v </ | ||
+ | </ | ||
+ | |||
+ | === Bind-Mount Volume from Host - Readonly === | ||
+ | <code bash> | ||
+ | docker run -it -v </ | ||
+ | </ | ||
+ | |||
+ | === Bind-Mount Volume from Host - Modern way === | ||
+ | <code bash> | ||
+ | docker run -it --mount type=bind, | ||
+ | </ | ||
+ | |||
+ | === Bind-Mount Volume from Host - Readonly - Modern way === | ||
+ | <code bash> | ||
+ | docker run -it --mount type=bind, | ||
+ | </ | ||
+ | |||
+ | === Set ENV for Container === | ||
+ | <code bash> | ||
+ | export VAR1=muh1 | ||
+ | docker run -it -e VAR1 --env VAR2=muh2 | ||
+ | </ | ||
+ | |||
+ | ==== Container List ==== | ||
+ | <code bash> | ||
+ | docker ps -a | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | docker container ls -a | ||
+ | </ | ||
+ | |||
+ | ==== Container stop ==== | ||
+ | <code bash> | ||
+ | docker stop < | ||
+ | </ | ||
+ | |||
+ | ==== Container remove ==== | ||
+ | <code bash> | ||
+ | docker rm < | ||
+ | </ | ||
+ | |||
+ | ==== Container Logs ==== | ||
+ | <code bash> | ||
+ | docker logs < | ||
+ | </ | ||
+ | |||
+ | ==== System ==== | ||
+ | === Cleanup === | ||
+ | Removes anything that is not in use. | ||
+ | <code bash> | ||
+ | docker system prune -a | ||
+ | </ | ||
+ | |||
+ | ===== Docker-Compose ===== | ||
+ | === Create Deployment === | ||
+ | <code bash> | ||
+ | docker-compose up -d | ||
+ | </ | ||
+ | |||
+ | === Stop Deployment === | ||
+ | <code bash> | ||
+ | docker-compose stop | ||
+ | </ | ||
+ | |||
+ | === Remove Deployment === | ||
+ | Removes containers, networks, ... but NO volumes! | ||
+ | <code bash> | ||
+ | docker-compose down | ||
+ | </ | ||
+ | |||
+ | === Remove Deployment - WITH VOLUMES === | ||
+ | Removes containers, networks, ... AND volumes! | ||
+ | <code bash> | ||
+ | docker-compose down --volumes | ||
+ | </ |