0%
Container operations
- docker ps -> running container
- docker ps -a -> all containers including stopped ones
- docker run
[-d#Background running#]
[–name=]
[-rm#Clean container after stopping#]
[-p #Open port<3000/tcp|4000/udp>#]
[-e ]
:v
- docker exec [-it#interact#] -> execute shell command in the container
- docker attach -> Not recommended, attach to container shell
- docker start|stop|restart -> start, stop and restart the container
- docker rm $(docker ps -a|grep Created|awk ‘{print $1}’) -> Delete the container that failed to start
Mirror operation
- docker commit [-a “author name”] [-m “information description”] :v -> Submit the container into a mirror
- docker images -> View all current images
- docker save -o -v.tar :v -> package the image in tar compression format
- docker load -i -v.tar -> Unzip the image tar and import it
- docker system df -v -> Check the disk occupied by the image
- docker export -o .tar -> Export the image directly from the container to avoid the image becoming larger after multiple commits.
- docker import :v -> The image exported through export must be imported through import
Other commands
- Docker system prune –volumes -> You can clean the cache after the save fails.
- docker system prune -a -> If the above one does not work, you can use this one to clean it all. The image and container will be lost.
- dockerd –iptables=false -> An error will be reported when running under wsl. Use this to disable the firewall.
Install docker on ubuntu20.4
- apt-get install ca-certificates curl gnupg lsb-release
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg
- echo “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs ) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update
- apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin