Docker operation Daquan

1. Installation
yum install -y docker
2. Start
service docker start
3. Turn on automatic startup
systemctl enable docker.service
4. Search for mirrors
docker search image name
5. Download the mirror
docker pull image name
6. Run the container
docker run -it //Enter the image
-v /home/:/wwwroot //map /home to /wwwroot in the container
-p 8000:80 //Map system port 8000 to container port 80
--name name//container ID
7. Enter the container
docker exec -it container name or id /bin/bash
docker attach ${CID}  into the container
8. View the container
docker ps // view all running containers
docker ps -a // view all containers
docker ps | grep wildfly | awk '{print $1}'  finds the container's image ID through a regular expression
9. Delete the container
docker rm container ID or name
doker rm $(docker ps -aq) // delete all containers
docker rmi $(docker images --quiet --filter "dangling=true")  delete unused images
docker ps -a | grep wildfly | awk '{print $1}' | xargs docker rm -f  remove containers using regular expressions
10. Stop the container
docker stop container ID or name
docker stop docker ps -q //停止所有正在运行容器
11.构建镜像
docker build --rm=true .  构建镜像
12.已下载镜像
docker images  显示已经安装的镜像
docker images --no-trunc  显示已经安装镜像的详细内容

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325682815&siteId=291194637