如何配置docker官方源并用yum安装docker

本文介绍了如何配置docker官方源并用yum安装docker ,分享给大家,希望对各位有帮助

一、docker的官方安装文档:

https://docs.docker.com/engine/installation/linux/centos/

由docker给的文档可以看出它也只是去配置了一个docker的yum源、然后就通过这个源来安装docker了;在这个文档下我们采用手工配置

的方式

二、配置一个docker用的源:

1、为docker 增加一个新的yum配置文件;touch /etc/yum.repos.d/docker.repo

touch /etc/yum.repos.d/docker.repo

2、docker.repo的内容如下

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=0 #我把这里设置成了0、说明我信任了这个源,不对它的rpm进行检察
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

三、安装docker:

sudo yum install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package             Arch         Version                Repository            Size
=====================================================================================================================================
Installing:
 docker-ce            x86_64        17.03.1.ce-1.el7.centos        docker-ce-stable         19 M
Installing for dependencies:
 docker-ce-selinux        noarch        17.03.1.ce-1.el7.centos        docker-ce-stable         28 k

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

Total download size: 19 M
Installed size: 19 M
Is this ok [y/d/N]: y

四、直接下载rpm包的方式来安装:

1、我在安装docker的时候发现下载的速度只有3kB/s 然而文件大小有19M;就在我感觉安装无望的时候、我机智的想到了自己直接把rpm下载下来

看了下docker.repo 、发现centos7的源地址是 https://download.docker.com/linux/centos/7/$basearch/stable 所以我只要去

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

用迅雷(我是会员有加速)把rpm包下载下来就行了

下载如下文件:

docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

五、安装docker:

ll
total 19096
-rwxrwxrwx 1 jianglexing jianglexing 19521288 May 30 20:05 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 jianglexing jianglexing  29108 May 30 20:15 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
[root@workstudio docker]# yum localinstall *
Loaded plugins: fastestmirror, langpacks
Examining docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm: docker-ce-17.03.0.ce-1.el7.centos.x86_64
Marking docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm to be installed
Examining docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm: docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch
Marking docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.0.ce-1.el7.centos will be installed
---> Package docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package         Arch     Version             Repository                        Size
=====================================================================================================================================
Installing:
 docker-ce        x86_64    17.03.0.ce-1.el7.centos     /docker-ce-17.03.0.ce-1.el7.centos.x86_64        65 M
 docker-ce-selinux    noarch    17.03.0.ce-1.el7.centos     /docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch    43 k

Transaction Summary
=====================================================================================================================================
Install 2 Packages

Total size: 65 M
Installed size: 65 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                 1/2
setsebool: SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
 Installing : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                     2/2
 Verifying : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                     1/2
 Verifying : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                 2/2 

Installed:
 docker-ce.x86_64 0:17.03.0.ce-1.el7.centos          docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos          

Complete!

六、启动docker:

[root@workstudio docker]# systemctl start docker
[root@workstudio docker]# ps -ef | grep docker
root    4458   1 1 20:22 ?    00:00:00 /usr/bin/dockerd
root    4465  4458 0 20:22 ?    00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root    4589  4333 0 20:22 pts/1  00:00:00 grep --color=auto docker

七、测试docker是否能成功运行:

[root@workstudio docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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 ID:
 https://cloud.docker.com/

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

如下是第一次运行hello-world 这个docker-image 由于它还不存在于本地、所以要下载它、这可能要用一点时间!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 详解Docker源码编译安装

    最近在尝试阅读Docker源码,一直想弄明白docker关于namespace等的代码的在哪,以及怎么触发.然而在阅读时发现根本找不到代码...想着还是先源码安装下docker,然后边运行边打印些调试信息看看再说 安装之前 Docker源码需在docker容器编译环境中编译,所以先安装docker,安装环境依旧是ubuntu14.04 echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee

  • ubuntu16.10安装docker17.03.0-ce并配置国内源和加速器

    说明:这个针对docker-ce安装,ce和ee的区别是前者是社区版,后者是企业版 1.  配置Ubuntu的源,不然慢的去哭吧.参考https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/注意版本要对应.我的源配置见附件http://xiazai.jb51.net/201705/yuanma/sources_jb51.rar. 2. 安装docker,按照官方教程https://docs.docker.com/engine/installation/l

  • Ubuntu Docker 源码编译(1.9.1 )详解

    Ubuntu Docker 源码编译: 网上对Ubuntu Docker 源码编译的资料有很多,但是对于具体如何操作,和命令的实现不是多细致,经过我一番折腾,终于把源码编译搞定,这里记录下,以便以后使用参考, 一.系统环境 Ubuntu14.04 desktop 64位 二.安装Docker(Docker内编译Docker) $ sudo apt-get update $ sudo apt-get install wget $ wget -qO- https://get.docker.com/

  • 详解Docker 容器使用 cgroups 限制资源使用

    上一篇文章将到 Docker 容器使用 linux namespace 来隔离其运行环境,使得容器中的进程看起来就像爱一个独立环境中运行一样.但是,光有运行环境隔离还不够,因为这些进程还是可以不受限制地使用系统资源,比如网络.磁盘.CPU以及内存 等.为了让容器中的进程更加可控,Docker 使用 Linux cgroups 来限制容器中的进程允许使用的系统资源. 1. 基础知识:Linux control groups 1.1 概念 Linux Cgroup 可​​​让​​​您​​​为​​​系

  • 详解如何修改docker pull镜像源

    Docker Hub Mirror 为全球最大的Docker Registry(Docker Hub)提供在中国的镜像代理服务.Docker Hub Mirror会为中国的用户在国内的服务器上缓存诸多镜像 当用户的Docker设定了--registry-mirror参数后,用户的Docker下拉镜像时,首先去Docker Hub Mirror中查找镜像,若命中则说明该镜像已经在Docker Hub Mirror中缓存,用户直接从Docker Hub Mirror中下载:若没有命中,则说该镜像还没

  • 详解使用Docker容器来源码编译etcd

    背景 etcd是CoreOS公司开发的分布式键值对存储库.在Kubernetes中,我们需要使用etcd作为所有REST API对象的持久化存储. 不幸的是,在github的release中,CoreOS将etcd的二进制可执行文件都放在了亚马逊的S3存储上,在国内访问非常慢.因此,我们只能通过源码编译etcd. 过程 1. 下载etcd源码. $ git clone https://github.com/coreos/etcd.git $ cd etcd 2. 根据实际情况,选择合适的版本.

  • 如何配置docker官方源并用yum安装docker

    本文介绍了如何配置docker官方源并用yum安装docker ,分享给大家,希望对各位有帮助 一.docker的官方安装文档: https://docs.docker.com/engine/installation/linux/centos/ 由docker给的文档可以看出它也只是去配置了一个docker的yum源.然后就通过这个源来安装docker了:在这个文档下我们采用手工配置 的方式 二.配置一个docker用的源: 1.为docker 增加一个新的yum配置文件:touch /etc/

  • 使用YUM 安装 docker的方法步骤

    如下图所示: 如果版本在Centos 7.0以上就可以了. 查看当前系统内核版本的命令如下: uname -r 运行结果如下图: 第二步:清理已经安装的docker(如果没有安装过,可以跳过此步) 清理命令如下: yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-

  • centos7安装docker容器的超详细步骤记录

    目录 环境要求: 步骤如下: 一.删除之前安装的docker(若之前未安装过,此步骤省略…) 二.虚拟机联网,安装yum工具 三.设置docker镜像源 四.安装docker(网速慢的需要等会) 五.启动docker前准备** 六.启动docker 总结 环境要求: centos7.0以上版本(docker支持最低版本) 步骤如下: 一.删除之前安装的docker(若之前未安装过,此步骤省略…) 进入centos根目录执行以下命令(\ 是linux系统种命令换行符,如果命令过长,可以用\来换行)

  • 安装Docker配置阿里云镜像加速(图文教程)

    目录 docker安装环境准备: 环境查看: 安装Docker: 一.下载需要的安装包: 二.设置Docker镜像仓库: 三.安装Docker相关内容 启动Docker: 卸载Docker: 阿里云镜像加速: docker安装环境准备: 配置一台可以上网的虚拟机: 需要一台可以使用的虚拟机,这里使用的是Linux的centos7系统配置docker环境. 这样配置的虚拟机就可以流畅运行docker的学习环境了. 环境查看: #查看系统内核是否是3.0以上的 uname -r #查看系统版本:ca

  • Centos7下安装Docker Engine

    一.先决条件 首选需要一个64位操作系统和3.10或者更版本的内核. 查看当前内核版本: $ uname -r 3.10.0-229.el7.x86_64 二.yum安装Docker Engine 安装Docker Engine有两种方式,我们先选择yum安装,并且Docker官方提供了yum源. 1.使用普通用户sudo或者root登录到你的服务器,更新yum,确保你的软件都是最新的 $ sudo yum update 2.添加Docker的yum源 $ sudo tee /etc/yum.r

  • CentOS/RedHat 6.5 离线安装Docker

    说明 1.由于是离线下载,需要提前下载好需要的依赖包 2.使用的版本为Centos6.5 3.不升级内核 安装过程 一.下载依赖包(使用能联网的节点) 依赖包已经下载好就跳过这步 使用有网络的节点 1.安装downloadonly插件使用yum下载rpm包 # yum install yum-plugin-downloadonly 使用方法: yum install --downloadonly(只下载不安装) --downloaddir=rpm包下载的目录 安装的组件名 2.下载docker需

  • 详解Windows 利用 WSL2 安装 Docker 的2种方式

    目录 一.安装 WSL 先决条件 二.安装 Docker 前的准备 三.Windows 安装 Docker 一.安装 WSL 先决条件 必须运行 Windows 10 版本 2004 及更高版本(内部版本 19041 及更高版本)或 Windows 11.(来自官网的说明) 二.安装 Docker 前的准备 控制面板->程序和功能->启用或关闭Windows功能->勾选 适用于Linux的Windows子系统 重启电脑 打开应用商城搜索 WSL ,可根据自己需求选择安装 Linux 发行

  • 在Ubuntu15.04上安装Docker的步骤以及基本用法

    简介 Docker 是一个开源项目,为开发者和系统管理员提供了一个开放的平台,在任何地方通过打包和运行应用程序作为一个轻量级的容器.Docker 在软件容器内自动部署应用程序.Docker 最开始由 Solomon Hykes 作为 dotCloud 一个内部开发项目,一个企业级的 PaaS (platform as a service 服务平台),该软件现在由 Docker 社区和 Docker 公司维护. 我们可以通过 Docker 官方提供的 KVM 与 Docker 的图片更加形象的知道

  • 详解CentOS7用阿里云Docker Yum源在线安装Docker 17.03.2

    参考文档 官方Docker安装文档:https://docs.docker.com/install/linux/docker-ce/centos 阿里云Docker安装文档:https://yq.aliyun.com/articles/110806 一键安装Docker https://github.com/cookcodeblog/OneDayDevOps/blob/master/components/docker/install_docker_ce.sh 安装步骤 删除已安装的Docker

  • 详解CentOS配置Nginx官方的Yum源

    一直都在使用阿里云购买的centos进行项目部署,最近在本地机器搭建了虚拟机进行某些项目联系时,却发现使用命令yum -y install nginx不能安装nginx,本地centos系统的yum仓库并没有nginx,查找资料得以解决,做记录如下: 由于yum源中没有我们想要的nginx,那么我们就需要创建一个"/etc/yum.repos.d/nginx.repo"的文件,其实就是新增一个yum源. [root@localhost ~]# vim /etc/yum.repos.d/

随机推荐