Docker的版本分为Docker-ce社区版和Docker-ee企业版,想了解更多能够去官网查看
其中Docker-ce分为stable和edge版本linux
安装前先在官网查看Docker支持的平台,不一样系统下的安装方法也均可以在官网找到,这里以在CentOS7下安装为例docker
OS requirements
To install Docker CE, you need a maintained version of CentOS 7. Archived versions aren’t supported or tested.
The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.
The overlay2 storage driver is recommended.
查看系统需求提示须要一个处于维护版本的CentOS7便可ubuntu
Uninstall old versions
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
若是以前安装过Docker,根据提示先清除老版本的Dockercentos
[root@centos7 ~]# yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
推荐的方式,便于安装和升级bash
须要安装yum-config-manager来更方便的管理yum仓库,yum-config-manager在yum-utils包中,因此先安装yum-utilsapp
[root@centos7 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
安装完后添加Docker-ce的官方源ide
[root@centos7 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
开启edge版本后,在选择指定版本安装时就能看到edge版本了ui
[root@centos7 ~]# yum-config-manager --enable docker-ce-edge
查看仓库列表检查是否添加成功this
[root@centos7 ~]# yum repolist
[root@centos7 ~]# yum install docker-ce
先列出Docker仓库中可用的版本再选择安装,@表明已安装的软件包,返回的列表取决于启用了哪些仓库
其中EL是RedHatEnterpriseLinux的简写,其中el5/6/7的软件包用于Red Hat 5/6/7.x, CentOS 5/6/7.x, and CloudLinux 5/6/7.下的安装centos7
[root@centos7 ~]# yum list docker-ce --showduplicates | sort -r 已加载插件:fastestmirror 可安装的软件包 Loading mirror speeds from cached hostfile docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
执行命令yum install docker-ce-<VERSION STRING>
安装
[root@centos7 ~]# yum install docker-ce-18.03.1.ce-1.el7.centos
[root@centos7 ~]# systemctl start docker
[root@centos7 ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9db2ca6ccae0: Pull complete Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc Status: Downloaded newer image for hello-world:latest Hello 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 the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
包方式安装须要下载.rpm文件进行安装,但当须要更新docker的时候也必须下载安装包来安装,下载地址
[root@centos7 ~]# yum install docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
[root@centos7 ~]# systemctl start docker
[root@centos7 ~]# docker run hello-world
[root@centos7 ~]# yum remove docker-ce [root@centos7 ~]# rm -rf /var/lib/docker