Skip to content

Instantly share code, notes, and snippets.

@lukaszlach
Last active September 23, 2021 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszlach/646ec941b94980757410f6f50042b40b to your computer and use it in GitHub Desktop.
Save lukaszlach/646ec941b94980757410f6f50042b40b to your computer and use it in GitHub Desktop.

Docker Webinar

Łukasz Lach, Docker Captain | 2021

https://lach.dev/ | https://github.com/lukaszlach/

Docker Masters | http://dockermasters.pl/

Docker Workshop | http://dockerworkshop.pl/

Build-time

Code everywhere

docker run -it \
    -p 8080:8080 \
    -v "$PWD:/home/coder/project" \
    -u "$(id -u):$(id -g)" \
    codercom/code-server

https://github.com/cdr/code-server

Remote build cache

export DOCKER_BUILDKIT=1
docker build \
  --cache-from \
      registry-gitlab.gog.com/project/image:latest \
  -t image \
  .

Perfect Docker image

docker run -i hadolint/hadolint < Dockerfile
docker run -v /var/run/docker.sock:/var/run/docker.sock goodwithtech/dockle alpine:3.9

Mangle build context

RUN --mount=type=bind,target=/context \
    cp -a /context/. /app/ && \
    find /app -type d -name ".git" | xargs rm -rf

Run-time

Detach from a container

docker run -it --name alpine alpine:3.9
^PQ
docker attach alpine

Command on-demand

docker run -d --name nginx nginx
docker run -it --net container:nginx cmd.cat/curl/ab/ngrep/tcpdump/ip/nmap/netstat
docker run -it --pid container:nginx cmd.cat/htop/ps/strace 
docker run -it --pid container:nginx cmd.cat/rsync/tar/zip/find find /proc/1/root/etc/nginx

https://github.com/lukaszlach/commando

Container filesystem

Get the process ID of ANY process running inside the container:

ps aux | grep nginx
docker top nginx

Explore the container filesystem without using Docker:

sudo ls -lach /proc/27090/root/

Explore the container filesystem using other Docker container:

docker run --rm -it \
  --pid container:nginx -v $PWD:/host \
  cmd.cat/bash/tar/zip/rsync/scp/curl/wget bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment