【docker 入门 - 01】- Docker 在 Centos7 上安装与测试
一、学习文档
官网网站: https://www.docker.com
官方安装文档:https://docs.docker.com/install/linux/docker-ce/centos/
最好的文档和学习路劲,都是来自官方的一手资料!当然,文档写的不好的除外。。。
<注>:英文还能凑合的,尽量去官网安装,毕竟能够跟的上步伐!
这里的解释顺序按照普通的安装步骤走,可能会和官方顺序有点不同。
以下的安装步骤都需要网络的支持哦,如果实在虚拟机中安装的,注意要外网支撑哦!
二、OS requirements (系统要求)
To install Docker CE, you need a maintained version of CentOS 7. Archived versions aren’t supported or tested.
The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.
The overlay2 storage driver is recommended.
官方要求系统版本: Centos 7
安装的 Docker 为 docker-ce,即社区版
三、 Install using the repository(指定依赖的仓库)
这里,我们可以更新一下 yum 的依赖仓库。
SET UP THE REPOSITORY(设置依赖仓库)
1. Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
这里可能需要更新一下有关 yum 工具的一些依赖工具,比如 提供了 yum-config-manager (yum 配置管理)的工具 yum-utils,还有提供 设备持久化数据映射 与 1vm2 的 devicemapper 设备映射存储驱动。
更新命令如下:
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
2. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
使用下面的命令来设置稳定版的仓库。
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
3. 这里只展示安装稳定版的,如果需要更多更详细的说明,请访问 docker 官方文档
四、 Uninstall old versions(卸载老旧的 docker 依赖)
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
以前的老旧的 docker 版本叫做 docker 或者 docker-engine。这里你可能需要卸载这些老旧的依赖,卸载命令如下:
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce.
五、INSTALL DOCKER CE(安装 docker 社区版,这个足够用了)
1. Install the latest version of Docker CE, or go to the next step to install a specific version:(如果你要安装最新的 docker-ce 版本,则直接使用下面的命令,如果需要指定某个版本,则先查看第 2 条说明)
$ sudo yum install docker-ce
注: 如果这里你指定了多个 docker 仓库,则可能安装到不是稳定的版本,具体查看官网信息。一般按照上面的步骤,是没有问题的,这里只是做一下说明。
2. To install a specific version of Docker CE, list the available versions in the repo, then select and install:(想要安装某个特定版本的 docker-ce,这里会列出你想要选择的 可用版本,这里从最高版本到最低版本为 从上到下展示,命令如下:)
$ yum list docker-ce --showduplicates | sort -r
展示出来的结果可能如下:
docker-ce.x86_64 18.09.0.ce-1.el7.centos docker-ce-stable
这是一个列表,一般会有多个版本,如果你想要安装某个特定的版本,则选择第二列,即 18.09.0.ce-1.el7.centos ,版本号为 “-” 这个短线前面的部分,比如这个的 18.09.0.ce,则安装命令如下:
这里需要指定你 docker-ce 的版本
$ sudo yum install docker-ce-18.09.0.ce
这个的原始命令为:
$ sudo yum install docker-ce-<VERSION STRING>,其中 <VERSION STRING> 为第二列 短线 “-” 前面的部分,组合起来,就可以安装到指定版本的 docker-ce。
六、Docker 启动测试
1. 启动 Docker
$ sudo systemctl start docker
2. Verify that docker is installed correctly by running the hello-world image.(通过运行 docker 界的 hello-world,来确认我们的 docker 安装是否正确)
$ sudo docker run hello-world
如图,出现图中红框内的文字,则代表 docker 安装成功了!

3. 如果想让 docker 设置开启激动,则命令如下:
$ sudo systemctl enable docker
七、Docker 简单命令及学习指导(其实我也是个菜鸡,但我觉着大方向不会错的)
查看 docker 中的信息,比如有多少个容器啊,镜像啊之类的,具体自己看。
docker info
学习 docker 命令,可以使用帮助命令查看手册,有什么命令不知道的,忘了的,可以通过下面的命令来查看
docker --help
如果想要查看某个命令的详细用法,则使用如下命令:(<command> 这个是你想要查询的某个命令)
docker <command> --help
八、如果你想要安装 阿里云的加速镜像
默认的加速镜像可能会比较慢,当然这个你可以自己决定,我用的程度也不是很深,也是借鉴别人的经验!
如果你没有阿里云账号,是可以通过支付宝直接注册登录的,毕竟都是一个体系的,放心用即可!
阿里云还有一个手机监控的 APP 哦,能直接在手机上输入命令,控制你的服务器,救急用还是挺好的,毕竟你不是时时刻刻都带着电脑到处跑吧,哈哈!
1. 在阿里云官网搜索栏中输入 “容器镜像服务”,会出现一个 “容器镜像服务 > 控制台”,直接点击进入
2. 左侧会有一个 “镜像加速器”,点击进去
3. “加速器地址” 下面的链接就是你的加速地址
4. 在 “操作文档” 一栏,选择你的系统,这里我们选择 “CentOS”
1. 安装 / 升级 Docker 客户端,一般不用管
2. 修改或者添加文件 /etc/docker/daemon.json
命令如下:
vim /etc/docker/daemon.json
内容修改为:(一看后面就像个数组,看是也是可以设置多个地址的啊,但是这里用一个就够了,多余的再说吧)
{
"registry-mirrors": ["这里是你的加速地址哦,千万不要写我"]
}
3. 让配置文件生效,并重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
好了,docker 的安装与简单测试到这里就完成了!!!
祝各位好运!!!
祝各位好运!!!
祝各位好运!!!
转载请注明出处 【苏子九霄】,谢谢!
【docker 入门 - 01】- Docker 在 Centos7 上安装与测试的更多相关文章
- Centos7上安装docker (转)
Centos7上安装docker Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如 ...
- Docker(2)--Centos7 上安装部署
Centos7 上安装docker Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比 ...
- centos7上安装docker社区版
container(容器) docker(集装箱) 容器的优点 1. 启动速度快 2. 节省资源 3. 兼容性高 保证机器正常上网 #ping www.baidu.com CPU需要支持虚拟化 # g ...
- centos7上安装docker-ce社区版
报错:Error: docker-ce-selinux conflicts with 2:container-selinux-2.12-2.gite7096ce.el7.noarch 转载:http: ...
- 在 CentOS7 上安装 MySQL5.7
在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...
- 在CentOS7上安装和使用ZooKeeper最新版本(V3.4.12)
0.ZooKeeper文档 http://zookeeper.apache.org/doc/r3.4.11/zookeeperOver.html 1.准备 在CentOS7上安装zookeeper时, ...
- 在centos7上安装Jenkins
在centos7上安装Jenkins 安装 添加yum repos,然后安装 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins ...
- 在 CentOS7 上安装 zookeeper-3.4.9 服务
在 CentOS7 上安装 zookeeper-3.4.9 服务 1.创建 /usr/local/services/zookeeper 文件夹: mkdir -p /usr/local/service ...
- 在 CentOS7 上安装 MongoDB
在 CentOS7 上安装 MongoDB 1 通过 SecureCRT 连接至 CentOS7 服务器: 2 进入到 /usr/local/ 目录: cd /usr/local 3 在当前目录下创建 ...
随机推荐
- 【mysql】字段类型和长度的解释
int(11)最大长度是多少,MySQL中varchar最大长度是多少? int(11)最大长度是多少? 在SQL语句中int代表你要创建字段的类型,int代表整型,11代表字段的长度. 这个11代表 ...
- window7 修改docker安装的machine 位置
win7下安装docker ,默认的machine location 是在C:\users\xx\.docker\machine\machines 下面,为了不占用系统盘,想修改盘符位置 google ...
- ICE框架双工通讯+MVVM框架测试案例
准备 开发工具 VS2015 ICE框架 https://zeroc.com/ MVVMLight框架 ICE接口文件 #include "./Identity.ice" #inc ...
- [转]C# 4.7.2 安装
遇到提示 “无法建立到信任根颁发机构的证书链” 下载地址:https://files.cnblogs.com/files/z5337/NetFramework%E8%AF%81%E4%B9%A6.ra ...
- 安装Git Bash图文教程
1.下载Git Bash,下载地址 https://pan.baidu.com/s/1sllsi0d 2.双击Git-2.9.2-64-bit.exe,运行,进行安装:点击“Next” 3.设置安装路 ...
- 最大化等比例测试演化Demo-传统方法
demo-1: <!doctype html> <html> <head> <meta charset="utf-8"> <t ...
- asp源码微信扫码授权登陆电脑版
网站接入微信扫码登录并获取用户基本信息(完美绕过微信开放平台)电脑版网站实现微信扫码登录,注册会员还要设密码太麻烦,会员也记不住密码,采用微信扫码登录网站更方便,会员无需设密码,用他的微信做为系统登录 ...
- js滚动到指定位置
序言:在网络上百度,关键字:“js div滚动到指定位置”,结果基本上大同小异!各种大神都给我们总结出来了四种滚动到指定位置的办法,可惜再下愚钝,每个都不会用,所以写了一个超级简单的方法来使初学者一看 ...
- Android 开发 关于APP无法安装到Android模拟器上的问题
我们在创建一个app后,打算安装到Android模拟器上.可能会出现无法安装,或者提示已经安装无法卸载的问题.这个时候需要添加兼容CPU. 选择 build.gradle 文件打开添加如下代码: an ...
- Java数据类型(primitive)原始数据类型
1.小心别溢出来. 要确保变量能存下来所保存的值. 你无法用小杯子装大值.好吧,其实可以,但是会损失某些信息,也就是所说的溢位.当判断到所使用的容器不足以装载时,编译器会试着防止珍重情况发生.举例来说 ...