Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production.
| Tool | Description |
|---|---|
| Lazydocker | The lazier way to manage everything docker |
| Dive | A tool for exploring each layer in a docker image |
| Hadolint | Dockerfile linter, validate inline bash, written in Haskell |
| Depend on Docker {DoD} | Open-source project that helps you containerize your software |
| Grype | A vulnerability scanner for container images and filesystems |
| Trivy | Find vulnerabilities, misconfigurations, secrets |
| Ctop | Top-like interface for container metrics |
| Edgeshark | Discover and capture container network |
| Skopeo | Work with remote images registries |
| Dockerc | Container image to single executable compiler |
| Deploy multiple dockers with Docker Compose |
Articles/Talks
- Simple C program to allocate memory from the command-line. Useful to test programs or systems under high memory usage conditions
- One Dockerfile for Production and Development
- Fast Docker Builds With Caching (Not Only) For Python
- Alpine-machine-learning-base
Installation
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.shConfiguration
# modify for builtkit
vim /etc/docker/daemon.json
{
# activate buildkit by default
"features": {"buildkit": true},
"bip": "10.0.20.10/16",
"dns": ["172.18.18.101", "172.18.18.102"] ,
"dns-search": ["nameserver.com"] ,
"live-restore": true,
"log-opts": {"max-size": "25m", "max-file": "4"},
"insecure-registries" : ["registry.es:5000"] ,
"registry-mirrors": ["https://registry.es:5000"],
# subnet
"default-address-pools":
[
{"base":"10.1.0.0/16","size":24}
]
}
# for docker-compose add
export COMPOSE_DOCKER_CLI_BUILD=1
# Show docker configuration for Registries
cat $HOME/.docker/config.json
# SYSTEMD
sudo systemctl daemon-reload
sudo systemctl restart docker
# display docker enviroments variables
sudo systemctl show docker --property EnvironmentConfigure variables for proxy in docker daemon
Debug
The output you are showing is from buildkit, which is a replacement for the classic build engine that docker ships with. You can adjust output from this with the --progress option:
--progress string Set type of progress output (auto, plain, tty). Use plain to show container output
(default "auto")
Adding --progress=plain will show the output of the run commands that were not loaded from the cache. This can also be done by setting the BUILDKIT_PROGRESS variable:
export BUILDKIT_PROGRESS=plainMacOS
- Configuration for
docker-composecaveats and add it as plugin and colima for VM.
{
"cliPluginsExtraDirs": [
"/opt/homebrew/lib/docker/cli-plugins"
],
"auths": {},
"credsStore": "osxkeychain",
"currentContext": "colima"
}# ssh to VM
colima sshCommands
Run
docker run -it --entrypoint /bin/bash image:latestRun Ubuntu
docker run -it --rm ubuntu
apt update && apt install -y curl python3 python3-pip python3-venvRun IT-tools
docker run -d --name it-tools --restart unless-stopped -p 8080:80 corentinth/it-tools:latestNetworking
# Attach a running container to a network
docker network connect [network] [container]Logging
docker logs ID_CONTAINER -fInspect
# show IP Docker
docker inspect -f '{{.NetworkSettings.IPAddress}}' ID or Name
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ID or Name
# list all containers belonging to a network by name
docker inspect -f '{{range $key, $value := .NetworkSettings.Networks}}{{$key}} {{end}}' ID or Name
#show volumes
docker inspect -f '{{json .Mounts}}' ID | jq .System
# Show information about space used for Docker
docker system dfStats
docker statsSecurity
### SBOM generation (CycloneDX format)
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install cyclonedx-bom \
&& cyclonedx-py -o /install/sbom.jsonRegistry
- Add docker Registry insecure
"insecure-registries" : ["registry.es:5000"]- Create registry
docker run -d -p 5000:5000 --name registry registry:2
docker image tag ubuntu localhost:5000/myfirstimage
docker push localhost:5000/myfirstimage- Push image to Docker Registry
docker login -u <user> -p <pass> https://url
docker tag image:latest url/image:latest
docker push url/image:latestOperations
Stop all containers
docker stop $(docker ps -q)Show process machine
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged ubuntu top
docker exec -it CONTAINER_ID bash topShow volume information
docker run -it --rm -v /path/on/host:/vol busybox ls -l /volMove volume information to other volume
docker volume create --name newvolume && docker run --rm -it -v oldvolume:/from -v newvolume:/to alpine ash -c 'cd /from ; cp -av . /to' && docker volume rm oldvolumeDocker delete
Delete all
docker system prune -aDelete unused or dangling
Images, Containers, Volumes, and Networks
docker system prune
docker volume pruneDelete unused containers
docker rm $(docker ps -aq)Delete build cache
docker builder pruneDelete images dangling
docker rmi $(docker images -qf "dangling=true")
docker rmi $(docker images | grep "<none>" | awk '{print $3}')
# remove last 5 images
docker rm $(docker images -q | tail -n 5)Virtual machines
MCP
docker mcp secret set POSTGRES_PASSWORD=my-secret-password