Introduction to Docker
test installation:
docker container run hello-world
switch docker image repository
sudo mkdir -p /etc/docker
vim /etc/docker/daemon.json
Replace the mirror with your own.{ "registry-mirrors": ["https://yxzrazem.mirror.aliyuncs.com"] }
sudo systemctl daemon-reload; sudo systemctl restart docker
add user to docker group (you can run
docker
commands withoutsudo
)sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
- verify:
docker run hello-world
restart docker service
sudo service docker restart
list docker images:
docker images
ordocker image ls
list containers:
docker ps
; list all containers:docker ps -a
remove containers:
docker rm <container id 1> <container id 2> ...
; remove all stopped containers:docker rm $(docker ps -a -q status=exited)
ordocker container prune
run container:
docker run <container id>/<image id> <command>
; run container with interface:docker run -it <container id>/<image id> bash