Docker
docker statsLike Linux top
docker container prunedocker 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 lsFor 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/hostshttps://www.baeldung.com/ops/docker-volumes
docker run -v //c/:/c --rm -it alpine ls /cPostgreSQL 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 # Shelldocker run --rm -it -v $(pwd):/host_pwd busybox
docker inspect `docker ps | grep <container name> | cut -f1 -d" "` | more
docker run --rm -it alpinedocker run --rm -it -v $(pwd):/host_pwd \
ubuntu /bin/bash \
-c 'cd /host_pwd; exec bash'docker run --rm -it -v $(pwd):/host_pwd \
jenkins/ssh-agent /bin/bash \
-c 'eval $(ssh-agent) > /dev/null; echo $SSH_AUTH_SOCK; exec bash'docker run --name alpine-today --rm -it alpinedocker exec -it <mycontainer> bashdocker run -d alpine tail -f /dev/nullWorks: 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.
docker run -it --rm kroniak/ssh-client ssh root@example.com
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/
uname -a from a Docker container shows the kernel information of the Docker host, not the container itself, because Docker containers share the host's kernel.
Consider: /etc/os-release for OS details, which will match the Dockerfile/Containerfile origin.
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