Header: Docker

Docker Cheatsheet

2021-07-31

Docker commands are easily forgotten

 

Above image from scmagazine.com

Cleaning #

Remove dangling images

docker image prune
sh

Or remove:

docker system prune
sh

Updating #

Update images managed by Docker compose:

docker compose pull
docker compose up -d --remove-orphans
sh

Removing #

docker rmi [image name]
docker rm [container name]
sh

Expose Port #

docker run -p [host port]:[container port]
sh

Using Buildx to build image for ARM #

docker buildx build \
          --tag your-username/multiarch-example:latest \
          --platform linux/amd64,linux/arm/v7,linux/arm64 .
text

Display command output with Buildx #

Just add a --progress=plain flag.

Add IPv6 #

Disclaimer: may be inaccurate

In /etc/docker/daemon.json:

{
  "ipv6": true,
  "fixed-cidr-v6": "2001:3200:1::/64"
}
json

And run:

sudo systemctl reload docker
sh

This reload is graceful so that you don't need to stop containers.

Then in docker-compose.yml:

services:
  app:
    # ...
    networks:
      - app_net
networks:
  app_net:
    enable_ipv6: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 2001:db8:1::/64
          gateway: 2001:db8:1::1
yaml
Leave your comments and reactions on GitHub