centos7.2安装docker教程

hongda's blog

 

CentOS7.2 安装Docker

Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

通过 uname -r 命令查看你当前的内核版本

[root@localhost /]# uname -r
3.10.0-327.el7.x86_64

Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下:

yum -y install docker

启动docker:

[root@localhost /]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

查看具体错误信息:

复制代码

[root@localhost /]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2018-04-20 06:50:52 CST; 3min 57s ago
     Docs: http://docs.docker.com
  Process: 44005 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 44005 (code=exited, status=1/FAILURE)

4月 20 06:50:50 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
4月 20 06:50:50 localhost.localdomain dockerd-current[44005]: time="2018-04-20T06:50:50.921964698+08:00" level=warning msg="could not ...ound"
4月 20 06:50:50 localhost.localdomain dockerd-current[44005]: time="2018-04-20T06:50:50.927241794+08:00" level=info msg="libcontainerd...4010"
4月 20 06:50:51 localhost.localdomain dockerd-current[44005]: time="2018-04-20T06:50:51.936045098+08:00" level=warning msg="overlay2: the b...
4月 20 06:50:52 localhost.localdomain dockerd-current[44005]: Error starting daemon: SELinux is not supported with the overlay2 graph ...alse)
4月 20 06:50:52 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
4月 20 06:50:52 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
4月 20 06:50:52 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 20 06:50:52 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

复制代码

可以看出错误信息

Error starting daemon: SELinux is not supported with the overlay2 graph ...alse)
此linux的内核中的SELinux不支持 overlay2 graph driver ,解决方法有两个,要么启动一个新内核,要么就在docker里禁用selinux,--selinux-enabled=false
[root@localhost /]# vi /etc/sysconfig/docker

修改配置:

复制代码

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# from the atomic-registries package.
#

复制代码

在--selinux-enabled后面添加=false即可!

 

重新启动docker

复制代码

[root@localhost /]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@localhost /]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: false
 Native Overlay Diff: false
Logging Driver: journald
Cgroup Driver: systemd
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: docker-init
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  WARNING: You're not using the default seccomp profile
  Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 977.9 MiB
Name: localhost.localdomain
ID: 2QP3:PYDM:BLLS:P5QS:QGJN:N7GK:DAKV:ZWFG:FW54:FHS4:FCAN:6NR4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)

复制代码

测试运行hello-world

复制代码

[root@localhost /]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ... 
latest: Pulling from docker.io/library/hello-world
/usr/bin/docker-current: Get https://registry-1.docker.io/v2/library/hello-world/manifests/sha256:d5c74e6f8efc7bdf42a5e22bd764400692cf82360d86b8c587a7584b03f51520: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: request canceled (Client.Timeout exceeded while awaiting headers).
See '/usr/bin/docker-current run --help'.
[root@localhost /]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ... 
latest: Pulling from docker.io/library/hello-world
9bb5a5d4561a: Pull complete 
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for docker.io/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/

复制代码

启动重启命令:

复制代码

[hongdada@localhost home]$ systemctl stop docker.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[hongdada@localhost home]$ systemctl restart docker.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[hongdada@localhost home]$ systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 五 2018-04-20 08:11:34 CST; 12s ago
     Docs: http://docs.docker.com
 Main PID: 51878 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─51878 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-cu...
           └─51883 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-con...

复制代码

 

http://www.runoob.com/docker/centos-docker-install.html

https://www.cnblogs.com/amoyzhu/p/5261393.html

https://blog.csdn.net/11b202/article/details/21389067

http://www.21yunwei.com/archives/4437

分类: Docker,Linux

好文要顶关注我收藏该文

hongdada
关注 - 67
粉丝 - 25

+加关注

0

0

 

« 上一篇:Java 多线程中的任务分解机制-ForkJoinPool,以及CompletableFuture
» 下一篇:CentOS7.2中systemctl的使用

posted @ 2018-04-19 23:25 hongdada 阅读(1018) 评论(0) 编辑 收藏

 

刷新评论刷新页面返回顶部

注册用户登录后才能发表评论,请 登录 或 注册,访问网站首页。

【推荐】超50万VC++源码: 大型组态工控、电力仿真CAD与GIS源码库!
【免费】要想入门学习Linux系统技术,你应该先选择一本适合自己的书籍
【前端】SpreadJS表格控件,可嵌入应用开发的在线Excel
【推荐】企业SaaS应用开发实战,快速构建企业运营/运维系统

腾讯云0831

最新IT新闻:
· Visual Studio Team Services现更名为Azure DevOps
· Android Go设备销量恐低迷:Google Go应用下载仅破千万
· Microsoft Authenticator正式登陆Apple Watch
· “抖音”诉“伙拍”成北京互联网法院受理第一案
· 网易AI平台开放多项技术 助力网易七鱼智能客服升级
» 更多新闻...

华为云HC0905

最新知识库文章:

· 为什么说 Java 程序员必须掌握 Spring Boot ?
· 在学习中,有一个比掌握知识更重要的能力
· 如何招到一个靠谱的程序员
· 一个故事看懂“区块链”
· 被踢出去的用户

» 更多知识库文章...

历史上的今天:
2017-04-19 Dubbo 只注册,只订阅
2013-04-19 Attributes

 

公告

昵称:hongdada
园龄:6年
粉丝:25
关注:67

+加关注

 

随笔分类

  • AngularJs(3)
  • Asp.net(5)
  • C#(17)
  • CodeMemo(23)
  • CSS(2)
  • Data Algorithms(32)
  • Design mode(7)
  • Distributed(6)
  • Docker(16)
  • Dubbo(2)
  • Elasticsearch(2)
  • Extjs(19)
  • Git(5)
  • H5 plus(3)
  • Hadoop(1)
  • IDEA(10)
  • Interview(25)
  • JAVA(42)
  • JavaScript(43)
  • JQuery(8)
  • JVM(7)
  • Knockout(2)
  • Life(16)
  • Linq(7)
  • Linux(35)
  • Maven(5)
  • MongoDB(2)
  • MSSQL(19)
  • MVC(9)
  • MyBatis(4)
  • MySQL(9)
  • Net(12)
  • Network(2)
  • NodeJs(3)
  • Oracle(6)
  • Other(23)
  • Python(2)
  • RabbitMQ(7)
  • Redis(10)
  • Spark(2)
  • Spring(16)
  • SpringBoot(26)
  • Thread And Lock(18)
  • Vue(3)
  • Winform(2)
  • Zookeeper(5)

阅读排行榜

  • 1. IntelliJ IDEA 自动导入包 关闭重复代码提示(125152)
  • 2. Intellij IDEA 创建控制台项目,断点调试快捷方式(25358)
  • 3. Spring Boot 5 SpringSecurity身份验证(19596)
  • 4. CentOS7.2 设置静态ip(14609)
  • 5. IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用(14359)

评论排行榜

  • 1. IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用(3)
  • 2. WebApi 找到了与该请求匹配的多个操作(3)
  • 3. 反射 简单工厂模式(2)
  • 4. 分布式方面的问题收集(2)
  • 5. Spring Boot 5 SpringSecurity身份验证(2)

推荐排行榜

  • 1. IntelliJ IDEA 自动导入包 关闭重复代码提示(5)
  • 2. Java并发控制:ReentrantLock Condition使用详解(4)
  • 3. IntelliJ IDEA 的 Java 热部署插件 JRebel 安装及使用(2)
  • 4. CentOS7.2 设置静态ip(2)
  • 5. Ubuntu16.04 安装JDK Tomcat(1)

 

Copyright ©2018 hongdada

Powered By Cnblogs | Silence Theme By Esofar

你可能感兴趣的:(centos7.2安装docker教程)