Skip to content

Latest commit

 

History

History
101 lines (78 loc) · 2.43 KB

File metadata and controls

101 lines (78 loc) · 2.43 KB

Docker Workflows

Advanced multi-step sequences for Docker, covering development cycles and system administration.

Build and Run: 1. Build

Build a new image from the current directory and immediately run it. #build-run #dev

docker build -t $dev_image .

Build and Run: 2. Run

docker run -it --rm $dev_image

Compose Hard Rebuild: 1. Tear down

When 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 -v

Compose Hard Rebuild: 2. Rebuild

docker compose build --no-cache

Compose Hard Rebuild: 3. Start

docker compose up -d

Host Administration: 1. Privileged Container

If 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/bash

Host Administration: 2. Chroot

chroot /mnt/root /bin/bash

Export Container: 1. Export

Extract 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_all

Export Container: 2. Import

docker import $export_tar $new_base_image