更新于 2024-08-05
#Dockerfile构建
docker build --tag xxxxx .
#拷贝文件到容器
docker cp ./ xxxx:/home/xxx
#提交容器为镜像
docker commit 容器名 镜像名
docker ps -a # docker container ls -a
docker stop|start xxx
docker images
docker image rm xxxx
#运行容器
docker run -id[ --name xxxx][ --restart always][ -p aaa:bbb][ -v ccc:ddd] [image] /bin/bash
docker exec -it xxxx /bin/bash
systemctl status docker
sudo service docker start
systemctl edit docker
systemctl daemon-reload
systemctl enable docker
[Service]
Restart=always
# 卸载docker
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
# 安装docker
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
EOF
systemctl daemon-reload
systemctl restart docker
docker run --privileged
docker run --restart always