https://docs.docker.com/get-started/docker_cheatsheet.pdf
https://docs.docker.com/reference/
Hier meine meisten genutzen commands:
Container
Auflisten
docker ps -a
docker ps -aq
STOP
docker stop <container>
docker stop $(docker ps -aq)
Filter
docker ps -f name=xyz
docker ps --format "table {{.Names}}\t{{.ID}}\t{{.Image}}\t{{.Status}}\t{{.RunningFor}}}\t{{.Command}}\t{{.Ports}}"
Format
docker ps --format "table {{.Names}}\t{{.ID}}\t{{.Image}}\t{{.Status}}\t{{.RunningFor}}}\t{{.Command}}\t{{.Ports}}"
Löschen alle
docker rm $(docker ps -a -q)
Containers löschen mit Filter
docker container prune --filter="label=app"
Images
Auflisten
docker images -aq
docker image ls
Löschen
docker rmi <images name/id>
docker image rm $(docker images -aq)
Volumes
Auflisten
docker volume ls
Löschen
docker volumes rm $(docker volume ls -q)
Network
Auflisten
docker network ls
Erstellen
docker network create <name>
Löschen
docker network rm $(docker network ls -q)
LOGS
docker logs <container id>
docker logs --details --follow <container id>
Kombinationen
Löscht alle Containers
docker container stop $(docker container ls -aq) && docker system prune -af --volumes
docker stop $(docker ps -aq) && docker rm $(docker ps -a -q) && docker rmi $(docker volume ls -q)
Build & RUN & EXEC
Build
docker build - < Dockerfile
docker build .
docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
docker build
For example, run this command to use a directory called docker in the branch container:
docker build https://github.com/docker/rootfs.git#container:docker
RUN
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker run --name test -d nginx:alpine
EXEC
docker exec -it <conteiner> sh
..
Service
systemctl status docker
systemctl start docker
Docker Login
docker login -u username --password-stdin
docker login --username=myusername
PROXY Konfiguration:
sudo nano ~/.docker/config.json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.domain.ch:9999",
"httpsProxy": "http://proxy.domain.ch:9999",
"noProxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
}
}
danach mit dem Docker Account anmelden und der account wird verschlüsselt in der config.json gespeichert:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "xxxxxxxx"
}
},
"proxies": {
"default": {
"httpProxy": "http://proxy.domain.ch:9999",
"httpsProxy": "http://proxy.domain.ch:9999",
"noProxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
}
}
Verschidenes
Version
docker version
Prune (löschen)
docker container prune
docker image prune -a
docker volume prune -a
docker system prune