Docker安装linux系统安装(亲自测试验证过)

1.安装一些必要的系统工具

1.1.命令

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

1.2.sample

[root@izwz91h49n3mj8r232gqwez ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.7.3-3.el7 will be installed
---> Package lvm2.x86_64 7:2.02.180-10.el7_6.2 will be installed
--> Processing Dependency: lvm2-libs = 7:2.02.180-10.el7_6.2 for package: 7:lvm2-2.02.180-10.el7_6.2.x86_64
--> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.180-10.el7_6.2.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.180-10.el7_6.2.x86_64
--> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.180-10.el7_6.2.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.180-10.el7_6.2.x86_64
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.2 will be installed
---> Package lvm2-libs.x86_64 7:2.02.180-10.el7_6.2 will be installed
--> Processing Dependency: device-mapper-event = 7:1.02.149-10.el7_6.2 for package: 7:lvm2-libs-2.02.180-10.el7_6.2.x86_64
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.149-10.el7_6.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================
 Package                                                    Arch                                Version                                             Repository                            Size
===============================================================================================================================================================================================
Installing:
 device-mapper-persistent-data                              x86_64                              0.7.3-3.el7                                         base                                 405 k
 lvm2                                                       x86_64                              7:2.02.180-10.el7_6.2                               updates                              1.3 M
Installing for dependencies:
 device-mapper-event                                        x86_64                              7:1.02.149-10.el7_6.2                               updates                              188 k
 device-mapper-event-libs                                   x86_64                              7:1.02.149-10.el7_6.2                               updates                              187 k
 lvm2-libs                                                  x86_64                              7:2.02.180-10.el7_6.2                               updates                              1.1 M

Transaction Summary
===============================================================================================================================================================================================
Install  2 Packages (+3 Dependent packages)

Total download size: 3.1 M
Installed size: 7.9 M
Downloading packages:
(1/5): device-mapper-event-libs-1.02.149-10.el7_6.2.x86_64.rpm                                                                                                          | 187 kB  00:00:03     
(2/5): device-mapper-event-1.02.149-10.el7_6.2.x86_64.rpm                                                                                                               | 188 kB  00:00:03     
(3/5): device-mapper-persistent-data-0.7.3-3.el7.x86_64.rpm                                                                                                             | 405 kB  00:00:03     
(4/5): lvm2-2.02.180-10.el7_6.2.x86_64.rpm                                                                                                                              | 1.3 MB  00:00:00     
(5/5): lvm2-libs-2.02.180-10.el7_6.2.x86_64.rpm                                                                                                                         | 1.1 MB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          625 kB/s | 3.1 MB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 7:device-mapper-event-libs-1.02.149-10.el7_6.2.x86_64                                                                                                                       1/5 
  Installing : 7:device-mapper-event-1.02.149-10.el7_6.2.x86_64                                                                                                                            2/5 
  Installing : 7:lvm2-libs-2.02.180-10.el7_6.2.x86_64                                                                                                                                      3/5 
  Installing : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                            4/5 
  Installing : 7:lvm2-2.02.180-10.el7_6.2.x86_64                                                                                                                                           5/5 
  Verifying  : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                            1/5 
  Verifying  : 7:lvm2-libs-2.02.180-10.el7_6.2.x86_64                                                                                                                                      2/5 
  Verifying  : 7:lvm2-2.02.180-10.el7_6.2.x86_64                                                                                                                                           3/5 
  Verifying  : 7:device-mapper-event-1.02.149-10.el7_6.2.x86_64                                                                                                                            4/5 
  Verifying  : 7:device-mapper-event-libs-1.02.149-10.el7_6.2.x86_64                                                                                                                       5/5 

Installed:
  device-mapper-persistent-data.x86_64 0:0.7.3-3.el7                                                     lvm2.x86_64 7:2.02.180-10.el7_6.2                                                    

Dependency Installed:
  device-mapper-event.x86_64 7:1.02.149-10.el7_6.2                 device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.2                 lvm2-libs.x86_64 7:2.02.180-10.el7_6.2                

Complete!

2.添加软件源信息

2.1.命令

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2.2.sample

[root@izwz91h49n3mj8r232gqwez ~]# sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

3.更新 yum 缓存

sudo yum makecache fast
[root@izwz91h49n3mj8r232gqwez ~]# sudo yum makecache fast

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                                    | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                                        | 3.5 kB  00:00:00     
epel                                                                                                                                                                    | 3.2 kB  00:00:00     
extras                                                                                                                                                                  | 3.4 kB  00:00:00     
mysql-connectors-community                                                                                                                                              | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                                                   | 2.5 kB  00:00:00     
mysql56-community                                                                                                                                                       | 2.5 kB  00:00:00     
updates                                                                                                                                                                 | 3.4 kB  00:00:00     
(1/2): docker-ce-stable/x86_64/updateinfo                                                                                                                               |   55 B  00:00:04     
(2/2): docker-ce-stable/x86_64/primary_db                                                                                                                               |  19 kB  00:00:04     
Metadata Cache Created
[root@izwz91h49n3mj8r232gqwez ~]# 

4.安装 Docker-ce

sudo yum -y install docker-ce
[root@izwz91h49n3mj8r232gqwez ~]# sudo yum -y install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package 3:docker-ce-18.09.0-3.el7.x86_64 already installed and latest version
Nothing to do

5.启动 Docker 后台服务

sudo systemctl start docker
[root@izwz91h49n3mj8r232gqwez ~]# sudo systemctl start docker

6.测试验证 测试运行 hello-world

[root@izwz91h49n3mj8r232gqwez ~]# 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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@izwz91h49n3mj8r232gqwez ~]# 

由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行。

你可能感兴趣的:(Docker安装linux系统安装(亲自测试验证过))