Docker
Build an image
Section titled “Build an image”# Build the image for multiple architecturesdocker buildx build --platform linux/amd64,linux/arm64,linux/armv7 -t myregistry/myimage:latest .
Push an image to DockerHub
Section titled “Push an image to DockerHub”docker buildx push --platform linux/amd64,linux/arm64,linux/armv7 myregistry/myimage:latest
Run composer from docker
Section titled “Run composer from docker”docker run --rm -v $(pwd):/app composer
Quick start a ubuntu container
Section titled “Quick start a ubuntu container”docker run --rm -it ubuntu /bin/bash
Network
Section titled “Network”Create a network
Section titled “Create a network”sudo docker network create my_docker_network --subnet 172.46.0.0/20
Run a container on the freshly created network with a custom IP
Section titled “Run a container on the freshly created network with a custom IP”docker run --rm --net my_docker_network --ip 172.46.0.1 -p 8080:80 nginx
When using UFW, allow the traffic to the previously created container
Section titled “When using UFW, allow the traffic to the previously created container”sudo ufw route allow proto tcp from any to 172.46.0.1 port 80
Check if it works
Section titled “Check if it works”curl http://{public_ip}:8080 ## Should return the nginx welcome page
Remove dangling volumes
Section titled “Remove dangling volumes”docker volume rm `docker volume ls -q -f dangling=true`