docker

Table of Contents

1. Creating images for other platforms

  • You need to have QEMU installed for your distro

    # default driver can't do multi-arch
    docker buildx create --name bob --driver=docker-container
    
    docker buildx use bob
    docker buildx build --tag geekodour/caddy:2.7.6 -o type=image --platform=linux/arm64,linux/amd64 .
    OR
    docker buildx build --builder bob --tag geekodour/caddy:2.7.6 -o type=image --platform=linux/arm64,linux/amd64 .
    
  • Note: This will only build, docker images will not list the built image apparently based on my exp.

2. Push

docker buildx build --push --tag geekodour/caddy:2.7.6 -o type=image --platform=linux/arm64,linux/amd64 .

3. Clear

  • docker rm -vf $(docker ps -aq) : To delete all containers including its volumes use
  • docker rmi -f $(docker images -aq) : To delete all the images
  • docker system prune -a --volumes : Delete everything

4. Others

  • pid of processes runnin inside the container
    • docker container top <container_id>
    • The pid allows to identify and use all the namespaces of the container from additional processes started on host.
    • sudo nsenter -n -t $pid ip addr : Here we can run the ip command in that container's network namespace from the host. Even if ip command is not installed in the container.

Created: 2024-07-16 Tue 16:44

Validate