一、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
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 由于它还不存在于本地、所以要下载它、这可能要用一点时间!

八、添加docker 中国官方源:

vi  /etc/docker/daemon.json

加入下面的源:

{
"registry-mirrors":["https://registry.docker-cn.com"]
}

重新加载源并重启docker :

systemctl daemon-reload
systemctl restart docker

九、开启ip_forward, 让容器能够访问互联网

如果仅仅是想临时启用IP路由转发功能:

1) #echo 1 > /proc/sys/net/ipv4/ip_forward

2) #sysctl -w net.ipv4.ip_forward=1

以上两种方法都可能立即开启路由功能,但如果系统重启,或执行了

# service network restart

命令,所设置的值即会丢失,如果想永久保留配置,可以修改/etc/sysctl.conf文件

将 net.ipv4.ip_forward=0改为net.ipv4.ip_forward=1

配置docker官方源并用yum安装docker的更多相关文章

  1. CentOS7 下 yum 安装 Docker CE

    前言 Docker 使用越来越多,安装也很简单,本次记录一下基本的步骤. Docker 目前支持 CentOS 7 及以后的版本,内核要求至少为 3.10. Docker 官网有安装步骤,本文只是记录 ...

  2. yum 安装docker后 无法启动

    一,yum安装docker yum -y install docker 启动docker service docker start 报错: journalctl -xe Error starting ...

  3. Docker:从头开始基于CentOS-Minimal安装Docker

    基础环境:win10+vmware 14 一.CentOS-Minimal安装 虚拟机安装CentOS-Minimal的步骤不多说,网络选Net,硬件不需要的什么声卡打印机全都删掉没什么问题,然后ce ...

  4. 如果您无法使用Docker的存储库来安装Docker CE

    如果您无法使用Docker的存储库来安装Docker CE,则可以下载.deb适用于您的发行版的 文件并手动安装.每次要升级Docker CE时都需要下载新文件. 转到https://download ...

  5. yum安装Docker及入门使用

    一.安装 1.配置yum源 # vim /etc/yum.repos.d/docker.repo [dockerrepo] name=Docker Repository baseurl=https:/ ...

  6. CentOS 7使用yum安装Docker

    安装依赖 # 配置阿里云源 # 备份 cp /etc/yum.repos.d/CentOS-Base.repo{,.bak'_'`date +%Y%m%d_%H%M%S`} # 下载 wget -O ...

  7. CentOS7.0 yum安装 docker

    一.安装docker 1.Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker . root 用户登录操作! 通过  ...

  8. yum安装Docker

    特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...

  9. 【已解决】CentOS7使用yum安装Docker显示错误:cannot find a valid baseurl for repo: base/7/x86_64

    不得不说,Docker 要求 CentOS 系统的内核版本高于 3.10,这就让有些人开始头疼了,而要查看具体的版本可以用以下命令 uname -r 当然,CentOS 6.8版本也能安装Docker ...

随机推荐

  1. html: 仿制soundmanager2右上角面板

    仿制 http://schillmania.com/projects/soundmanager2/#volume 右上角面板 <style type="text/css"&g ...

  2. Mac平台下部署UE4工程到iOS设备的流程

    1.开发环境 UE4.Xcode.iOS版本情况如下: 1.UE4:当前最新版本Unreal Engine 4.17.2. 2.Xcode:当前最新版本Xcode9.0. 3.iOS:当前最新版本iO ...

  3. 获取电脑的 SN 码

    wmic bios get serialnumber

  4. 用ActiveX 创建自己的comboBox 控件(二)

    3.0 添加事件 3.1 添加OnSelChange 事件 当用户选中列表项的时候触发该事件.(不只是选择改变时触发,本次选择和上次相同时也触发): 添加完成后,在ActivexcomboBox.id ...

  5. Java语法 [HelloWorld]

    程序代码: public class lqx {// AAAAANBBBBCKJKSLJIOQL/*请手打哦!*/ public static void main (String[] args) { ...

  6. Python自动化测试用例设计--测试类型

    1.前言 WEB自动化测试时候测试哪些类型,下面将介绍一下: 2. 测试类型 2.1 测试静态内容 静态内容测试是最简单的测试,用于验证静态的.不变化的UI 元素的存在性.例如: 每个页面都有其预期的 ...

  7. [leetcode]81. Search in Rotated Sorted Array II旋转过有序数组里找目标值II(有重)

    This is a follow up problem to Search in Rotated Sorted Array, where nums may contain duplicates. 思路 ...

  8. 标志寄存器在Debug中的表示

    在Debug中,标志寄存器是按照有意义的各个标志位单独表示的. 下面列出Debug对我们已知的标志位的表示.

  9. cookie、sesstion、strorage

    1. cookie 第一:每个特定的域名下最多生成20个cookie  (数量上) <IE6: 20    |   >ie7:50   |  firefox: 50     |   IE ...

  10. 微信小程序之----获取设备信息

    1. 获取系统信息        wx.getSystemInfo(OBJECT)        wx.getSystemInfoSync() 同步获取系统信息                回调常用 ...