centos7安装docker总结

04 Mar 2018 centos7安装docker总结

最近工作中需要用到docker,所以决定自己搭建一个docker环境,于是选择在virtualbox上安装centos7虚拟机,并在虚拟机上安装docker,没搭建环境之前,觉得应该很简单,没想到折腾了好长时间。比如安装的centos7版本不支持docker,最后导致重装,所以特此记录下安装步骤及注意事项。

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

2)开始安装虚拟机,如果需要图形化界面,在安装最后一步记得选择带图形安装;

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

4)安装virtualbox增强功能,一般会提示缺少gcc、make、perl和其他库文件,需安装和系统内核版本一致的库文件,否则不能安装virtualbox增强功能,例如:

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...

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

# yum install gcc make perl
# yum install kernel-devel-$(uname -r)
# 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

再次安装virtualbox增强功能,成功安装。

5)安装docker:

$ curl -fsSL https://get.docker.com/ | sh
$ systemctl start docker
$ systemctl status docker
$ systemctl enable docker

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

6)运行docker hello world示例:

$ 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
$ 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/

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

LEo at 23:55

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏小狼的世界

Kubernetes基础:查看状态、管理服务

在Kubernetes中创建一个Deployment 部署就会在Node上创建一个Pod,Pod是Kubernetes中对于一组容器以及与容器相关的资源的集合。...

4141
来自专栏cs

python所遇到的坑

6264
来自专栏LuckQI

容器Docker学习系列七~系统信息学习

前面了解的Docker学习的本地镜像管理还有镜像仓库的命令学习,怎么说呢其实这些命令已经够我们平常使用的了。但是如果随着发展我们在系统程序调优上可能就需要了解更...

1371
来自专栏大魏分享(微信公众号:david-share)

从一张图看Devops全流程

一、持续交付工具链全图 ? 上图源自网络。上图很清晰地列出了CD几个阶段使用的工具。 CD的工具链很长,但并不是每个模块所有工具都那么流行;换言之,我们在每个模...

1.5K9
来自专栏运维

k8s集群之kubernetes-dashboard和kube-dns组件部署安装

k8s集群之kubernetes-dashboard和kube-dns组件部署安装

3182
来自专栏Java技术分享

如何解决ajax跨域问题

由 于此前很少写前端的代码(哈哈,不合格的程序员啊),最近项目中用到json作为系统间交互的手段,自然就伴随着众多ajax请求,随之而来的就是要解决 ajax的...

2488
来自专栏码匠的流水账

docker化360的pika

2121
来自专栏小狼的世界

kubeadm安装kubernetes V1.11.1 集群

如果想要用二进制方法安装最新版本的Docker,可以参考我之前的文章在Redhat 7.3中采用离线方式安装Docker

7701
来自专栏小狼的世界

Docker修改daemon.json后无法启动的问题

最近在整理Docker和Kubernetes中的日志与相关配置,在尝试通过/etc/docker/daemon.json配置Docker的log-driver参...

4781
来自专栏Laoqi's Linux运维专列

CentOs7.3 搭建 RabbitMQ 3.6 单机多实例服务

4607

扫码关注云+社区

领取腾讯云代金券