Docker
docker stats
Like Linux top
docker container prune
docker history <Image Name>
Show the infor on each layer in the specified Docker image.
i.e. Images with Name "".
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
To avoid: Add --rm
to docker build
.
docker network ls
For example:
docker run .... --network="host"
docker run -p 8080:80 <image>
The first port is Docker host, the second port is Docker container.
docker run --add-host=example.com:10.0.0.1 --rm -it alpine grep example.com /etc/hosts
https://www.baeldung.com/ops/docker-volumes
docker run -v //c/:/c --rm -it alpine ls /c
PostgreSQL specific:
docker run --rm --network=host -v "//c/:/c" postgres pg_dump --format=custom -d db_name --verbose -f "/c/tmp/dump.backup"
Busybox ("The Swiss Army knife of Embedded Linux"):
docker run -v //c/:/c --rm -it busybox ash # Shell
docker inspect `docker ps | grep <container name> | cut -f1 -d" "` | more
docker run --rm -it alpine
docker run --name alpine-today --rm -it alpine
docker exec -it <mycontainer> bash
docker run -d alpine tail -f /dev/null
Works: docker exec -it ccc sh -c 'echo $MY_ENV_VAR'
Doesn't work (for various reasons): docker exec -it ccc echo $MY_ENV_VAR
docker exec -t -i my-container sh -c 'my-command; exit $?'
docker info > /dev/null 2>&1
if [ $? != "0" ]; then
echo ERROR: Docker daemon is not running, and/or you\'re not in the \'docker\' group.>&2
exit 1
fi
Containers are not completely isolated from their hosts (unlike VMs.) Their atually run directly on the host, but just in their own namespace.
Like CMD
, except that the docker run
parameters (if present) get appended to it. If not present, then the CMD
contents are used.
Overridden by docker
's --entrypoint
parameter.
High-level industry-standard container runtime. Implements Open Container Initiative (OCI)-compliant runtimes, between OS and Docker.
A standalone CNCF project.
Good post: https://www.docker.com/blog/containerd-vs-docker/
Index digest vs Manifest digest
Index digest: sha256:73ce...
Manifest digests:
- linux/amd64: sha256:746f...
- linux/arm74: sha256:20d3...
docker pull bitwarden/self-host:2024.7.2-beta
...
docker image ls --digests bitwarden/self-host
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
bitwarden/self-host 2024.7.2-beta sha256:20d3... b5a485c3c35a 11 days ago 1.01GB
bitwarden/self-host 2024.7.2-beta sha256:73ce... b5a485c3c35a 11 days ago 1.01GB