Docker安装Linux中 -

概述

Docker是一个开项目,诞生于2013年初,最初是dotCloud公司内部的一个业余项目。它基于Google公司推出的Go语言实现。

项目后来加入了Linux基金会,遵从了Apache2.0协议,项目代码在GitHub上进行维护。Docker自开源后受到广范的关注和讨论,以至于dotCloud公司后来都改名为Docker Inc。

RedHat已经在其RHEL6.5中集中支持Docker;Google也在其PaaS产品中广泛应用。Docker的目标是实现经量级的操作系统虚拟化解决方案。Docker的基础是Linux容器(LXC)等技术。

在LXC的基础上Docker进行了进一步的封装,让用户不需要关心容器的管理,使得操作更加简单。用户操作Docker的容器就像操作一个快速轻量级的虚拟机一样简单。

 - centos 下安装Docker 文档
 - 
 - 地址:https://docs.docker.com/install/linux/docker-ce/centos/

一、Docker 安装

1.1 确定是centos7的版本
[root@aubin ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

1.2 yum安装gcc相关
-,确定centos7能上外网
-,yum -y install gcc
-,yum -y install gcc-c++

1.3 卸载旧版本
$ sudo yum remove docker \
					docker-client \
					docker-client-latest \
					docker-common \
					docker-latest \
					docker-latest-logrotate \
					docker-logrotate \
					docker-engine

1.4 安装docker
[root@aubin ~]# yum install docker

1.5 启动docker
[root@aubin ~]# systemctl start docker

1.6 查看版本
[root@aubin ~]# docker version

1.7 测试运行 hello-world
[root@aubin ~]# docker run hello-world
由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行。

二、拉取的时候出现的一些问题:
在这里插入图片描述
解决方法:(4步走)

[root@aubin ~]# yum install bind-utils    // 安装dig工具[root@aubin ~]# dig @114.114.114.114 registry-1.docker.io
    
    ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> @114.114.114.114 registry-1.docker.io
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56325
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 512
    ;; QUESTION SECTION:
    ;registry-1.docker.io.		IN	A
    
    ;; ANSWER SECTION:
    registry-1.docker.io.	34	IN	A	34.205.88.205
    registry-1.docker.io.	34	IN	A	35.169.133.189
    registry-1.docker.io.	34	IN	A	3.221.133.86
    registry-1.docker.io.	34	IN	A	3.224.75.242
    registry-1.docker.io.	34	IN	A	3.224.11.4
    registry-1.docker.io.	34	IN	A	3.210.179.11
    registry-1.docker.io.	34	IN	A	34.202.247.184
    registry-1.docker.io.	34	IN	A	52.2.169.2
    
    ;; Query time: 32 msec
    ;; SERVER: 114.114.114.114#53(114.114.114.114)
    ;; WHEN:410 13:55:46 +07 2020
    ;; MSG SIZE  rcvd: 177
   
   
    选择上面命令执行结果中的一组解析放到本机的/etc/hosts文件里做映射:
    比如这里选的一个34.205.88.205 registry-1.docker.io
三  [root@aubin ~]# vim /etc/hosts

	34.205.88.205 registry-1.docker.io    

四  [root@aubin ~]# 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
    1b930d010525: Pull complete 
    Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
    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/get-started/
     

三、检验

[root@aubin docker]# docker image
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              fce289e99eb9        15 months ago       1.84 kB

猜你喜欢

转载自blog.csdn.net/qq_38129621/article/details/105434256