Advanced multi-step sequences for Docker, covering development cycles and system administration.
Build a new image from the current directory and immediately run it. #build-run #dev
docker build -t $dev_image .docker run -it --rm $dev_imageWhen things get weird, tear down the compose stack completely, rebuild it without using the cache, and start it back up. #nuke-compose #rebuild #fresh
docker compose down -vdocker compose build --no-cachedocker compose up -dIf you need to administer the underlying host from within Docker, you can run a privileged container, mount the host's root filesystem, and chroot into it to get full access on the host. #admin #host-mount #recovery
docker run --privileged --net=host --pid=host -v /:/mnt/root -it $image /bin/bashchroot /mnt/root /bin/bashExtract the filesystem of a running or stopped container and turn it into a brand new base image. #flatten #snapshot #export
docker export -o $export_tar $container_alldocker import $export_tar $new_base_image