Docker支持多种操作系统,如Ubuntu、CentOS、Windows、MacOS等系统。这次我自己用的是CentOS系统。
我先确认一下自己当前服务器的系统版本信息:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]#
接下来,我们开始安装docker:
执行以下命令:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
验证一下是否安装成功:
[root@localhost ~]# docker --version
Docker version 19.03.12, build 48a66213fe
[root@localhost ~]#
启动docker:
sudo systemctl start docker
查看docker状态:
systemctl status docker
停止 docker 服务:
systemctl stop docker
很多初学者都会忘记这步,如果不启动并直接执行docker相关命令,会报以下错误信息:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?