目录
[6. 检查是否安装成功,成功会显示相应版本,否则安装失败](#6. 检查是否安装成功,成功会显示相应版本,否则安装失败)
一、将docker安装到云服务器步骤
1.更新系统yum版本
bash
yum update
2.安装所需依赖
bash
yum install -y yum-utils device-mapper-persistent-data lvm2
3.添加docker仓库设置(使用的是阿里云)
bash
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.安装docker引擎
bash
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5.启动docker并开启自动启动
html
systemctl enable docker
(设置docker开机自动启动)
systemctl enable docker
6. 检查是否安装成功,成功会显示相应版本,否则安装失败
bash
docker --version
二、docker常用命令
1.从docker镜像仓库搜索所有与mysql相关的镜像
bash
docker search mysql

2.从docker仓库拉取镜像
拉取mysql
html
docker search mysql
拉取nacos
html
docker pull nacos/nacos-server

3.启动镜像
html
docker pull nacos/nacos-server
html
docker run -d --name nacos -p 8848:8848 -p 9848:9848 -p 9849:9849 --privileged=true -e MODE=standalone --restart=always nacos/nacos-server

4.查看所有正在运行的docker容器
html
docker ps

5.查看所有的容器
html
docker ps -a

6.停止某个容器
html
docker stop +容器id

7.删除容器(先将运行的容器停止、再删除)
html
docker rm +容器id

8.查看容器的日志
html
docker logs -f 容器id
9.查看所有镜像
html
docker images

10.删除镜像
html
docker rmi +镜像id