Linux下安装docker

https://www.cnblogs.com/xred/p/3845215.html

 中间碰到的问题:

1、ssl认证问题,直接安装ca-certificates

2、yum命令不好使问题,redhat安装yum

3、vm无法连互联网问题,修改vm的配置,改成NAS

4、epel资源mirror错误问题,解决办法是修改epel.conf路径为base。

名词解释

名词

解释

备注

Selinux

安全增强型 Linux(Security-Enhanced Linux)简称 SELinux。它是一个 Linux 内核模块,也是 Linux 的一个安全子系统。

LXC

LXC为Linux Container的简写;Linux Container容器是一种内核虚拟化技术,可以提供轻量级的虚拟化,以便隔离进程和资源。LXCdocker的关系:(1Docker并不是LXC的替代品,Docker的底层就是使用了LXC来实现的。LXCLinux进程沙盒化,使得进程之间相互隔离,并且能够控制各进程的资源分配。
2)在LXC的基础之上,Docker提供了一系列更强的功能

EPEL

EPEL的全称叫 Extra Packages for Enterprise Linux 。EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源。

hop5.repo

Centos 6.x Package Repository

http://www.hop5.in/yum/el6/repoview/

一、禁用selinux


由于SelinuxLXC有冲突,所以需要禁用selinux。编辑/etc/selinux/config,设置两个关键变量。   
SELINUX=disabled
SELINUXTYPE=targeted

二、配置Fedora EPEL


1 sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

三、添加hop5.repo

 

cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo

四、安装Docker
sudo yum install docker-io

1执行安装命令:

[root@guang ~]# yum install docker-io

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package docker-io.x86_64 0:0.6.2-1.el6 will be installed

--> Processing Dependency: lxc >= 0.8.0 for package: docker-io-0.6.2-1.el6.x86_64

--> Processing Dependency: kernel-ml-aufs >= 3.10.5 for package: docker-io-0.6.2-1.el6.x86_64

--> Running transaction check

---> Package kernel-ml-aufs.x86_64 0:3.10.5-3.el6 will be installed

---> Package lxc.x86_64 0:1.0.11-1.el6 will be installed

--> Processing Dependency: lua-lxc(x86-64) = 1.0.11-1.el6 for package: lxc-1.0.11-1.el6.x86_64

--> Processing Dependency: lua-alt-getopt for package: lxc-1.0.11-1.el6.x86_64

--> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.11-1.el6.x86_64

--> Running transaction check

---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed

---> Package lua-lxc.x86_64 0:1.0.11-1.el6 will be installed

--> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.11-1.el6.x86_64

---> Package lxc-libs.x86_64 0:1.0.11-1.el6 will be installed

--> Running transaction check

---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================

 Package                                   Arch                              Version                                   Repository                       Size

=============================================================================================================================================================

Installing:

 docker-io                                 x86_64                            0.6.2-1.el6                               hop5                            1.3 M

Installing for dependencies:

 kernel-ml-aufs                            x86_64                            3.10.5-3.el6                              hop5                             33 M

 lua-alt-getopt                            noarch                            0.7.0-1.el6                               epel                            6.9 k

 lua-filesystem                            x86_64                            1.4.2-1.el6                               epel                             24 k

 lua-lxc                                   x86_64                            1.0.11-1.el6                              epel                             16 k

 lxc                                       x86_64                            1.0.11-1.el6                              epel                            124 k

 lxc-libs                                  x86_64                            1.0.11-1.el6                              epel                            257 k

Transaction Summary

=============================================================================================================================================================

Install       7 Package(s)

Total size: 35 M

Total download size: 289 k

Installed size: 160 M

Is this ok [y/N]: y

Downloading Packages:

(1/3): lua-alt-getopt-0.7.0-1.el6.noarch.rpm                                                                                          | 6.9 kB     00:00     

(2/3): lua-filesystem-1.4.2-1.el6.x86_64.rpm                                                                                          |  24 kB     00:00     

(3/3): lxc-libs-1.0.11-1.el6.x86_64.rpm                                                                                               | 257 kB     00:00     

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                         61 kB/s | 289 kB     00:04     

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Importing GPG key 0x0608B895:

 Userid : EPEL (6) <epel@fedoraproject.org>

 Package: epel-release-6-8.noarch (@/epel-release-6-8.noarch)

 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : lxc-libs-1.0.11-1.el6.x86_64                                                                                                              1/7

  Installing : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                         2/7

  Installing : lua-lxc-1.0.11-1.el6.x86_64                                                                                                               3/7

  Installing : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                         4/7

  Installing : lxc-1.0.11-1.el6.x86_64                                                                                                                   5/7

  Installing : kernel-ml-aufs-3.10.5-3.el6.x86_64                                                                                                        6/7

  Installing : docker-io-0.6.2-1.el6.x86_64                                                                                                              7/7

  Verifying  : docker-io-0.6.2-1.el6.x86_64                                                                                                              1/7

  Verifying  : lxc-1.0.11-1.el6.x86_64                                                                                                                   2/7

  Verifying  : lua-lxc-1.0.11-1.el6.x86_64                                                                                                               3/7

  Verifying  : lxc-libs-1.0.11-1.el6.x86_64                                                                                                              4/7

  Verifying  : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                         5/7

  Verifying  : kernel-ml-aufs-3.10.5-3.el6.x86_64                                                                                                        6/7

  Verifying  : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                         7/7

Installed:

  docker-io.x86_64 0:0.6.2-1.el6                                                                                                                             

Dependency Installed:

  kernel-ml-aufs.x86_64 0:3.10.5-3.el6     lua-alt-getopt.noarch 0:0.7.0-1.el6     lua-filesystem.x86_64 0:1.4.2-1.el6     lua-lxc.x86_64 0:1.0.11-1.el6    

  lxc.x86_64 0:1.0.11-1.el6                lxc-libs.x86_64 0:1.0.11-1.el6         

Complete!

2安装结果验证:

[root@guang ~]# docker -h

Usage of docker:

  -D=false: Debug mode

  -H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use

  -api-enable-cors=false: Enable CORS requests in the remote api.

  -b="": Attach containers to a pre-existing network bridge. Use 'none' to disable container networking

  -d=false: Daemon mode

  -dns="": Set custom dns servers

  -g="/var/lib/docker": Path to graph storage base dir.

  -p="/var/run/docker.pid": File containing process PID

  -r=false: Restart previously running containers

  -v=false: Print version information and quit

[root@guang ~]#

原文地址:https://www.cnblogs.com/guanghuiqq/p/11431917.html