docker安装
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 开机自启 sudo systemctl enable docker # 启动docker服务 sudo systemctl start docker
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["镜像地址"] } EOF # 重启docker sudo systemctl daemon-reload sudo systemctl restart docker
docker镜像命令
docker images
docker search softname
docker pull softname:version
docker rmi softname:version
docker rmi `docker images -q`
docker容器命令
docker run -it --name=defindName softname:version #进入容器的初始化指令 /bin/bash exit #退出容器 docker ps #查看正在运行的容器 docker ps -a #查看所有容器
docker run -id --name=defindName2 softname:version #不进入容器,后台运行 docker exec -it c2 /bin/bash #进入后台运行终端 -id创建的容器exit不会关闭
docker start defindName #开启容器 docker stop defindName #停止容器 docker rm defindName #删除容器 docker inspect defindName #查看容器信息