当前位置:   article > 正文

【CentOS】安装Docker教程

a dependency job for docker.service failed. see 'journalctl -xe' for details
前提条件

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。

 

首先, 查看系统是否支持:

               image

 

Docker有两种方式安装:

  1. 脚本安装
  2. Yum包安装

 

安装前注意:

  1. 本文针对CentOS 7 去安装
  2. 如果太久或者是特殊系统不要yum update
  3. 必需要root权限

 

一、Yum包安装
(1) 添加 docker,Yum源
  1. [root@localhost ~]# sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
  2. > [dockerrepo]
  3. > name=Docker Repository
  4. > baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
  5. > enabled=1
  6. > gpgcheck=1
  7. > gpgkey=https://yum.dockerproject.org/gpg
  8. > EOF
  9. [dockerrepo]
  10. name=Docker Repository
  11. baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
  12. enabled=1
  13. gpgcheck=1
  14. gpgkey=https://yum.dockerproject.org/gpg
(2) 安装 docker包
[root@localhost ~]# yum install docker-engine
(3) 启动守护 docker进程
  1. [root@localhost ~]# service docker start
  2. Redirecting to /bin/systemctl start docker.service
(4) 测试
  1. [root@localhost ~]# docker run hello-world
  2. Unable to find image 'hello-world:latest' locally
  3. latest: Pulling from library/hello-world
  4. ca4f61b1923c: Pull complete
  5. Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
  6. Status: Downloaded newer image for hello-world:latest
  7. Hello from Docker!
  8. This message shows that your installation appears to be working correctly.
  9. To generate this message, Docker took the following steps:
  10. 1. The Docker client contacted the Docker daemon.
  11. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  12. (amd64)
  13. 3. The Docker daemon created a new container from that image which runs the
  14. executable that produces the output you are currently reading.
  15. 4. The Docker daemon streamed that output to the Docker client, which sent it
  16. to your terminal.
  17. To try something more ambitious, you can run an Ubuntu container with:
  18. $ docker run -it ubuntu bash
  19. Share images, automate workflows, and more with a free Docker ID:
  20. https://cloud.docker.com/
  21. For more examples and ideas, visit:
  22. https://docs.docker.com/engine/userguide/

 

(5) 镜像加速 (可选)
  1. vim /etc/docker/daemon.json
  2. {
  3. "registry-mirrors": ["http://hub-mirror.c.163.com"]
  4. }
(6) 开机启动
[root@localhost ~]# systemctl enable docker.service

 

二、脚本安装 (感觉不太靠谱, 不推荐)

(1)  yum update

(2)  curl -sSL https://get.docker.com/ | sh

(3)  service docker start

(4)  docker run hello-world

 

启动时候会出现的错误:

  Job for docker.service failed. See 'systemctl status docker.service' and 'journalctl -xn' for details.

1: 防火墙之类的,

2: yum -y install docker

 

推荐文档:

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

http://www.docker.org.cn/book/install/supported-platform-17.html

转载于:https://www.cnblogs.com/EddieBlog/p/8796924.html

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号