Docker学习01:Centos7下安装Docker
安装Docker
1-查看Centos 版本:当前版本是Centos7.7,可采用当前方法
[root@ecs-x-large-2-linux-20200229160057 ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.7.1908 (Core) Release: 7.7.1908 Codename: Core
2-yum安装gcc相关
[root@ecs-x-large-2-linux-20200229160057 ~]# yum -y install gcc [root@ecs-x-large-2-linux-20200229160057 ~]# yum -y install gcc-c++
3-安装需要的软件包
[root@ecs-x-large-2-linux-20200229160057 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
4-设置stable镜像仓库
[root@ecs-x-large-2-linux-20200229160057 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo Loaded plugins: fastestmirror adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo
5-更新yum软件包索引
[root@ecs-x-large-2-linux-20200229160057 ~]# yum makecache fast
6-安装docker-ce
[root@ecs-x-large-2-linux-20200229160057 ~]# yum -y install docker-ce
7-启动docker
[root@ecs-x-large-2-linux-20200229160057 ~]# systemctl start docker
8-测试是否启动成功
[root@ecs-x-large-2-linux-20200229160057 ~]# docker version Client: Docker Engine - Community Version: 19.03.8 API version: 1.40 Go version: go1.12.17 Git commit: afacb8b Built: Wed Mar 11 01:27:04 2020 OS/Arch: linux/amd64 Experimental: false [root@ecs-x-large-2-linux-20200229160057 ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly.
END