centos7安装docker总结

最近工做中须要用到docker,因此决定本身搭建一个docker环境,因而选择在virtualbox上安装centos7虚拟机,并在虚拟机上安装docker,没搭建环境以前,以为应该很简单,没想到折腾了好长时间。好比安装的centos7版本不支持docker,最后致使重装,因此特此记录下安装步骤及注意事项。docker

1) 建立虚拟机,选择centos系统镜像,好比CentOS-7-x86_64-DVD-1708.iso,务必使用官方最新支持的版本,若是选择的镜像版本不对,会致使安装完docker没法运行;ubuntu

2)开始安装虚拟机,若是须要图形化界面,在安装最后一步记得选择带图形安装;centos

3)安装完毕,重启后,须要赞成许可才能进入系统,若是是命令行界面,记得仔细阅读提示信息,需输入相应的选项赞成许可才能进入系统;bash

4)安装virtualbox加强功能,通常会提示缺乏gcc、make、perl和其余库文件,需安装和系统内核版本一致的库文件,不然不能安装virtualbox加强功能,例如:app

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.6 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-693.el7.x86_64
Press Return to close this window...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

按照提示信息,安装所需的工具和库:curl

[root@ssli-centos7 ~]# yum install gcc make perl
[root@ssli-centos7 ~]# yum install kernel-devel-$(uname -r)
[root@ssli-centos7 ~]# rpm -qa kernel\*
kernel-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.el7.x86_64
kernel-devel-3.10.0-693.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

再次安装virtualbox加强功能,成功安装。ide

5)安装docker:工具

root@ssli-centos7:~$ curl -fsSL https://get.docker.com/ | sh
root@ssli-centos7:~$ systemctl start docker
root@ssli-centos7:~$ systemctl status docker
root@ssli-centos7:~$ systemctl enable docker
  • 1
  • 2
  • 3
  • 4

安装docker,并启动docker,而后将docker服务设置成开机自启动。ui

6)运行docker hello world示例:this

root@ssli-centos7:~$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
root@ssli-centos7:~$ docker run hello-world

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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

至此,成功在centos7上安装docker。

相关文章
相关标签/搜索