docker不是一个通用的容器,需要依赖linux内核环境运行;
Docker实质是已经运行的Linux下制造了一个隔离的文件环境,因此它执行的效率几乎等同于所部署的Linux主机,因此Docker必须部署在Linux内核的系统上,如果其他系统想部署Docker就必须安装一个虚拟Linux环境。
Docker运行在Centos7 64位系统上,内核版本必须在3.8以上;
cat /etc/redhat-release #查看系统相关信息
CentOS Linux release 7.9.2009 (Core)
uname -r #查看内核信息
3.10.0-1160.71.1.el7.x86_64
查看是否安装过docker
ps -ef|grep docker
安装过需要卸载旧的docker
1、安装gcc插件
sudo yum -y install gcc-c++
2、安装需要的软件包
sudo yum install -y yum-utils
3、设置阿里云docker的镜像仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast #重置yum安装索引
4、安装docker
docker-ce 社区版 而ee是企业版
yum install docker-ce docker-ce-cli containerd.io
5、查看是否按照成功
[root@localhost xxx]# docker version
Client: Docker Engine - CommunityVersion: 20.10.21API version: 1.41Go version: go1.18.7Git commit: baeda1fBuilt: Tue Oct 25 18:04:24 2022OS/Arch: linux/amd64Context: defaultExperimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
如果出现Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
说明是daemon没有启动,重启即可;则进行如下操作
systemctl daemon-reload
systemctl restart docker.service
6、在执行查看docker版本
docker version
这时候就可以看到client和server,就可以了
7、测试
执行:docker run hello-world
返回如下
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:e18f0a777aefabe047a671ab3ec3eed05414477c951ab1a6f352a06974245fe7
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/
因为本地新安装没有hello镜像,所以从仓库总拉取并执行