Tech/OSS/Docker

From lathama
< Tech‎ | OSS
Jump to navigation Jump to search

My stuffs

https://hub.docker.com/u/lathama/
https://lathama.net/git/lathama/Dockerfiles

Nuke everything

docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
docker builder prune -f

Dockerfile

ADD
COPY
ENV
EXPOSE
FROM
LABEL
STOPSIGNAL
USER
VOLUME
WORKDIR

Container Restart Policy

Stop a container from starting at boot or restarting

docker update --restart=no <container ID>

Docker Build

In the directory of the Dockerfile

$ docker build .

From a Git repo using the main branch and going to the bind9 directory

$ docker build https://lathama.net/git/lathama/Dockerfiles.git#master:bind9

Always pull fresh upstream images

$ docker build --pull https://lathama.net/git/lathama/Dockerfiles.git#master:bind9

Pushing to Docker Hub

make notes on the process here

Multi Arch on Docker

On Linux if you have qemu installed you can run docker containers for multi architecture like running ARM code on an X86 system.

Example

$ uname -a
Linux mini 6.1.0-31-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07) x86_64 GNU/Linux
$ docker run --platform=linux/arm/v7 -it arm32v7/busybox:stable uname -a
Linux 57c2c61a3144 6.1.0-31-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07) armv7l GNU/Linux

Setup

apt-get install qemu-system binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Notes