-
sudo snap install docker -
[Optional] Add GPU support:
- Install CUDA Toolkit
- Install nvidia-docker
- Check usage:
sudo docker run --gpus all nvidia/cuda:10.0-base nvidia-smi
-
Post-installation steps for Linux
sudo groupadd docker # Create the docker group.sudo usermod -aG docker $USER # Add your user to the docker group. -
Verify that Docker CE is installed correctly by running the Ubuntu image:
docker run docker/whalesay cowsay "HI $(docker --version)"
-
Run a container in an interactive mode:
docker run -it ubuntu bash -
To check are running containers:
docker ps -
Check containers:
docker ps -a -
Check images:
docker images -
Execute command in container:
docker exec -it <id> /bin/bash -
Build a image:
docker build --network host -t '<name>':'<version>' . -
Exit from a container without stopping it:
CTRL + P + Q -
Stop a container from outside of the container:
docker stop <container id or name> -
Kill a container from outside of the container
docker kill <container id or name> -
Restart a container:
docker start <container id> -
Attach to a container:
docker attach <container id> -
Create an image from a container:
docker commit <container id> <image name> -
Purging All Unused or Dangling Images, Containers, Volumes, and Networks
Docker provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):
docker system pruneTo additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:
docker system prune -a -
Port mapping:
docker run -d -p 5001:80 docker run -it -p 8885:8888 <name> -
Volume mapping:
docker run -it -v ~/Downloads:/data ubuntu /bin/bash -
Container logs in a detach mode:
docker logs <container_d> -
Other:
'-d' run in the background
'-it' launch interactive mode
Path to docker containers /var/lib/docker/aufs/diff/. Docker files
sudo ls -l /var/lib/docker/aufs/diff/
- Install QEMU:
sudo apt update -y && sudo apt upgrade -y && sudo apt install -y qemu-kvm bridge-utils libvirt-daemon virt-manager \ libvirt-clients libvirt-daemon-system qemu binfmt-support qemu-user-staticsudo adduser $USER libvirt - Enable support for aarch64 containers on your x86 workstation (This step will execute the registering scripts):
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - Testing the emulation environment:
#aarch64
docker run --rm -t arm64v8/ubuntu uname -m # Testing the emulation environment - Run ubuntu 24.04 aarch64 dicker:
docker run -it -p 1022:22 --platform linux/arm64/v8 ubuntu:24.04 bash