`
frank1998819
  • 浏览: 758081 次
  • 性别: Icon_minigender_1
  • 来自: 南京
文章分类
社区版块
存档分类

docker for CentOS 7 安装

 
阅读更多

1、安装 CentOS 7 64bit

   确保centos 最小内核版本3.10及其以上

 

$ uname -r
3.10.0-229.el7.x86_64

2、安装Docker(yum方式安装)

2.1、创建docker用户

 

2.2、添加docker用户到sudoers文件中

    #vim  /etc/sudoers 找到这一行:”root ALL=(ALL) ALL”,在其下面添加

    docker ALL=(ALL) ALL

 

3.安装docker

 

3.1. Log into your machine as a user with sudo or root privileges.

3.2. Make sure your existing yum packages are up-to-date.

$ sudo yum update

3.3.  Add the yum repo.

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

   

3.4. Install the Docker package.

$ sudo yum install docker-engine

[docker@localhost ~]$ sudo yum install docker-engine
[sudo] password for docker:
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00    
dockerrepo                                               | 2.9 kB     00:00    
extras                                                   | 3.4 kB     00:00    
updates                                                  | 3.4 kB     00:00    
(1/3): extras/7/x86_64/primary_db                                       | 165 kB  00:00:01    
(2/3): dockerrepo/primary_db                                            |  20 kB  00:00:01    
(3/3): updates/7/x86_64/primary_db                                      | 7.8 MB  00:04:32    
Determining fastest mirrors
 * base: mirrors.sina.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.12.1-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.12.1-1.el7.centos for package: docker-engine-1.12.1-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-engine-selinux.noarch 0:1.12.1-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                      Arch          Version                    Repository         Size
===============================================================================================
Installing:
 docker-engine                x86_64        1.12.1-1.el7.centos        dockerrepo         19 M
Installing for dependencies:
 docker-engine-selinux        noarch        1.12.1-1.el7.centos        dockerrepo         28 k

Transaction Summary
===============================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 19 M
Installed size: 79 M
Is this ok [y/d/N]: y(输入 y)

 

Downloading packages:
warning: /var/cache/yum/x86_64/7/dockerrepo/packages/docker-engine-selinux-1.12.1-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Public key for docker-engine-selinux-1.12.1-1.el7.centos.noarch.rpm is not installed
(1/2): docker-engine-selinux-1.12.1-1.el7.centos.noarch.rpm                                                          |  28 kB  00:00:01    
(2/2): docker-engine-1.12.1-1.el7.centos.x86_64.rpm                                                                  |  19 MB  00:01:05    
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                       295 kB/s |  19 MB  00:01:05    
Retrieving key from https://yum.dockerproject.org/gpg
Importing GPG key 0x2C52609D:
 Userid     : "Docker Release Tool (releasedocker) <docker@docker.com>"
 Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
 From       : https://yum.dockerproject.org/gpg
Is this ok [y/N]: y(输入 y)

 

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : docker-engine-selinux-1.12.1-1.el7.centos.noarch                                                                         1/2
restorecon:  lstat(/var/lib/docker) failed:  No such file or directory
warning: %post(docker-engine-selinux-1.12.1-1.el7.centos.noarch) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.12.1-1.el7.centos.noarch
  Installing : docker-engine-1.12.1-1.el7.centos.x86_64                                                                                 2/2
  Verifying  : docker-engine-selinux-1.12.1-1.el7.centos.noarch                                                                         1/2
  Verifying  : docker-engine-1.12.1-1.el7.centos.x86_64                                                                                 2/2

Installed:
  docker-engine.x86_64 0:1.12.1-1.el7.centos                                                                                               

Dependency Installed:
  docker-engine-selinux.noarch 0:1.12.1-1.el7.centos                                                                                       

Complete!

 

3.5. Start the Docker daemon.

$ sudo service docker start
[sudo] password for docker: 输入密码(root)
Redirecting to /bin/systemctl start  docker.service

3.6. Verify docker is installed correctly by running a test image in a container.

$ sudo docker run hello-world
   Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for 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.
 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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

 

 

3.7. 查看镜像信息

[docker@localhost ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              c54a2cc56cbb        12 weeks ago        1.848 kB


3.8. 获取镜像的详细信息

[docker@localhost ~]$ docker inspect c54a2cc56cbb ( 即 IMAGE ID  )
[
    {
        "Id": "sha256:c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc",
        "RepoTags": [
            "hello-world:latest"
        ],
        "RepoDigests": [
            "hello-world@sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2016-07-01T19:39:27.532838486Z",
        "Container": "562cadb4d17bbf30b58ab0f6a870be60c8d36d2e401bf637f1d2d7f8afbef666",
        "ContainerConfig": {
            "Hostname": "c65bc554a4b7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) CMD [\"/hello\"]"
            ],
            "Image": "sha256:0f9bb7da10de694b2babd0c1a3b75582a0db3395625cae5ab0fe537ce1cd831e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "1.10.3",
        "Author": "",
        "Config": {
            "Hostname": "c65bc554a4b7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/hello"
            ],
            "Image": "sha256:0f9bb7da10de694b2babd0c1a3b75582a0db3395625cae5ab0fe537ce1cd831e",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 1848,
        "VirtualSize": 1848,
        "GraphDriver": {
            "Name": "devicemapper",
            "Data": {
                "DeviceId": "2",
                "DeviceName": "docker-8:3-37159125-ff753638d0db8bd72bf5fdaee2daf93d080e9147197b2936e044717d417f18b9",
                "DeviceSize": "10737418240"
            }
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:a02596fdd012f22b03af6ad7d11fa590c57507558357b079c3e8cebceb4262d7"
            ]
        }
    }
]

 

4. docker 升级

4.1. 查看Docker版本

[docker@localhost ~]$ docker -v
Docker version 1.12.1, build 23cf638

 

4.2. 停止Docker , 如果Docker正在运行,先停掉。
[docker@localhost ~]$ sudo systemctl stop docker
[sudo] password for docker:  输入密码(root)

4.3. 升级docker
[docker@localhost ~]$ sudo yum -y update docker

Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                 | 3.6 kB  00:00:00    
dockerrepo                                                                                                           | 2.9 kB  00:00:00    
extras                                                                                                               | 3.4 kB  00:00:00    
updates                                                                                                              | 3.4 kB  00:00:00    
(1/2): extras/7/x86_64/primary_db                                                                                    | 166 kB  00:00:00    
(2/2): updates/7/x86_64/primary_db                                                                                   | 7.8 MB  00:00:05    
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
Package(s) docker available, but not installed.
No packages marked for update

 

 

 

分享到:
评论

相关推荐

    arm架构centos7安装docker

    安装步骤参考:https://blog.csdn.net/chkai123/article/details/126229727 docker离线安装 arm架构下离线安装docker docker centos7离线安装docekr 离线安装docker arm架构下安装docker arm架构centos7安装docker

    centos7.4离线安装docker

    我们将使用RPM软件包来完成安装,并且会参考提供的附件“CentOS7.4离线安装docker.doc”以及“docker-for-centos7.4.zip”中的详细指南。 首先,了解Docker是至关重要的。Docker是一种开源的应用容器引擎,允许...

    centos7.6离线安装docker-ce-19.03、nvidia-docker2

    离线环境下,在centos7.6系统上安装docker-ce-19.03,nvidia-docker2.4版本,其中docker-ce-19.03在docker-local.tar压缩文件里面,nvidia-docker2在nvidia-docker2.zip文件中。 具体安装流程如下: 1.安装docker ...

    centos6.8-离线安装docker环境所需的rpm

    由于CentOS 6.8的默认软件仓库中的版本较旧,不支持Docker CE(Community Edition),我们需要添加第三方仓库,如EPEL(Extra Packages for Enterprise Linux)。EPEL仓库提供了许多针对老版本CentOS的更新软件包。...

    centos6离线安装docker相关依赖包 及 自动安装脚本

    在CentOS 6环境下,离线安装Docker及其相关依赖是一项技术性的工作,因为这个版本的系统不直接支持Docker的最新版本。然而,通过一些手动步骤和利用离线安装包,我们可以完成这一任务。以下是对这个过程的详细说明。...

    Centos7 安装zookeeper for Docker.md

    Centos7 安装zookeeper for Docker.md 存放这里,让大家下载快捷一点

    Centos7 安装kafka for Docker.md

    Centos7 安装kafka for Docker.md 存放这里,让大家下载快捷一点

    离线安装docker20,for centos 7.9

    离线安装Docker CE(Community Edition)在某些网络环境受限的情况下是必要的,特别是对于CentOS 7.9这样的操作系统。Docker CE是一个流行的开源平台,它允许开发人员和系统管理员轻松地构建、部署和运行分布式应用...

    银河麒麟v10 sp1 server安装docker手册

    Error: Problem: cannot install the best candidate for the job - nothing provides container-selinux &gt;= 2:2.74 needed by docker-ce-3:20.10.17-3.el7.aarch64 (try to add '--skip-broken' to skip ...

    虚拟机Centos7搭建MQTT服务

    在本文中,我们将详细介绍如何在虚拟机CentOS7上搭建MQTT服务。MQTT(Message Queuing Telemetry Transport)是一种轻量级的发布/订阅消息协议,常用于物联网(IoT)设备之间的通信。CentOS7是一个稳定的Linux发行版,...

    docker-ce-17.12.1.ce for centos7

    本地直接通过docker官网安装由于网络原因经常终端,可直接下载最新版的docker本地rpm安装包

    Docker的安装配置及使用教程.pdf

    Docker的安装配置及使用教程如下: 一、Docker安装 1.Linux上安装Docker 首先,确保您的Linux系统满足Docker的安装要求。...确保您的Windows版本满足Docker for Windows的安装要求(通常是64位Window

    CentOS7 安装docker 解决启动不了的问题

    CentOS7安装docker 启动不了,在工作当中遇到这个问题,当时急的不清,网上资料又不多,不过经过自己的捣鼓终于解决了 这个问题! [root@test ~]# yum update [root@test ~]# yum install docker [root@test ~]# ...

    docker1.7-for-centos6.tar.gz

    docker1.7适用于centos6.8.................................................................

    docker安装教程.md

    访问Docker官网或使用其他方式获取Docker Desktop for Windows的安装程序。 2. **运行安装程序**: 执行下载的安装程序文件,按照安装向导的提示完成安装。 3. **配置系统功能**: 在安装过程中,可能需要启用...

    centos-7-docker.tar.gz

    WSL,centos系统,WSL (Win­dows Sub­sys­tem for Linux)

    Centos7 Redis-cluster for Docker.md

    Centos7 Redis-cluster for Docker.md 存放这里,让大家下载快捷一点

    CentOS-7-x86_64-Minimal-1708.zip

    标题中的"CentOS-7-x86_64-Minimal-1708.zip"表明这是一款基于x86_64架构的轻量级Linux发行版——CentOS 7的最小化安装镜像。CentOS是Community ENTerprise Operating System的缩写,它是一个开源、免费的操作系统,...

    docker-bugzilla-fig:由图管理的基于 docker 的 Bugzilla 安装

    访问安装 Fig 来管理多个相关的 Docker 容器。 运行以下 git clone(如果您愿意,请指定您选择的目录): git clone https://github.com/dklawren/docker-bugzilla-fig.git docker-bugzilla cd 进入您将 git ...

Global site tag (gtag.js) - Google Analytics