Docker安装 - CentOS7环境

安装Docker

我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上,建议3.10以上(ubuntu下要linux内核3.8以上, RHEL/Centos 的内核修补过, centos6.5的版本就可以——这个可以试试)

1. root账户登录,查看内核版本如下

[root@localhost ~]# uname -a
Linux localhost.qgc 3.10.-862.11..el7.x86_64 # SMP Tue Aug :: UTC x86_64 x86_64 x86_64 GNU/Linux

2. 把yum包更新到最新

[root@localhost ~]# yum update
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 bind-libs.x86_64.32.9.9.4-.el7 将被 升级
---> 软件包 bind-libs.x86_64.32.9.9.4-.el7_5. 将被 更新
---> 软件包 bind-libs-lite.x86_64.32.9.9.4-.el7 将被 升级
---> 软件包 bind-libs-lite.x86_64.32.9.9.4-.el7_5. 将被 更新
---> 软件包 bind-license.noarch.32.9.9.4-.el7 将被 升级
---> 软件包 bind-license.noarch.32.9.9.4-.el7_5. 将被 更新
...
...
验证中 : :bind-license-9.9.-.el7.noarch /
更新完毕:
bind-libs.x86_64 :9.9.-.el7_5.
bind-libs-lite.x86_64 :9.9.-.el7_5.
bind-license.noarch :9.9.-.el7_5.
bind-utils.x86_64 :9.9.-.el7_5.
完毕!
[root@localhost ~]#

3. 安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
...

4. 设置yum源

[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

5. 可以查看所有仓库中所有docker版本,并选择特定版本安装

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
* updates: centos.ustc.edu.cn
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 18.06..ce-.el7 docker-ce-stable
docker-ce.x86_64 18.06..ce-.el7 docker-ce-stable
docker-ce.x86_64 18.03..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 18.03..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.12..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.12..ce-.el7.centos docker-ce-stable
...

6. 安装Docker,命令:yum install docker-ce-版本号,我选的是17.12.1.ce,如下

[root@localhost ~]# yum install docker-ce-17.12..ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
base | 3.6 kB :
docker-ce-stable | 2.9 kB :
extras | 3.4 kB :
updates | 3.4 kB :
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.17.12.1.ce-.el7.centos 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-17.12..ce-.el7.centos.x86_64 需要
...

7.启动Docker,命令:systemctl start docker,然后加入开机启动,如下

[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

8. 验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

[root@localhost ~]# docker version
Client:
Version: 17.12.-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb ::
OS/Arch: linux/amd64 Server:
Engine:
Version: 17.12.-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb ::
OS/Arch: linux/amd64
Experimental: false

问题:Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 解决办法

$ systemctl daemon-reload
$ sudo service docker restart
$ sudo service docker status (should see active (running))
$ sudo docker run hello-world

爬一些常用Docker命令,更多命令详解,请访问:http://www.docker.org.cn/dockerppt/106.html:

-----------------     docker ps 查看当前正在运行的容器

-----------------    docker ps -a 查看所有容器的状态

-----------------    docker start/stop id/name 启动/停止某个容器

-----------------    docker attach id 进入某个容器(使用exit退出后容器也跟着停止运行)

-----------------    docker exec -ti id 启动一个伪终端以交互式的方式进入某个容器(使用exit退出后容器不停止运行)

-----------------    docker images 查看本地镜像

-----------------    docker rm id/name 删除某个容器

-----------------     docker rmi id/name 删除某个镜像

-----------------    docker run --name test -ti ubuntu /bin/bash  复制ubuntu容器并且重命名为test且运行,然后以伪终端交互式方式进入容器,运行bash

-----------------     docker build -t soar/centos:7.1 .  通过当前目录下的Dockerfile创建一个名为soar/centos:7.1的镜像

-----------------    docker run -d -p 2222:22 --name test soar/centos:7.1  以镜像soar/centos:7.1创建名为test的容器,并以后台模式运行,并做端口映射到宿主机2222端口,P参数重启容器宿主机端口会发生改变

参考:https://www.cnblogs.com/qgc1995/archive/2018/08/29/9553572.html

参考:https://www.cnblogs.com/yufeng218/p/8370670.html

参考:http://www.docker.org.cn/dockerppt/106.html

参考:https://www.cnblogs.com/forturn/p/9371841.html

Docker安装 - CentOS7环境的更多相关文章

  1. nexus3安装 - CentOS7环境

    nexus3安装 - CentOS7环境 使用nexus3管理docker镜像,配合rancher进行部署. 建资料卷 资料卷默认地址:/var/lib/docker/volumes/资料卷名/_da ...

  2. 一、docker安装CentOS7

    一.安装步骤 前提条件 Docker运行在CentOS7上,要求系统64位.系统内核版本为3.10以上. Docker是一个进程,一启动就两个进程,一个服务,一个守护进程.占用资源就非常少,启动速度非 ...

  3. docker安装与环境部署

    使用docker搭建环境 摘要 install docker start docker install docker-compose 部署upload-labs/sqli-labs 部署dvwa 部署 ...

  4. docker安装+测试环境的搭建---

    漏洞演练环境docker地址:http://vulhub.org/#/environments/ 环境:kali-linux-2017.2-amd64.iso 一.docker安装 1.先更新一波源: ...

  5. Docker 安装(centos7下)

    下面链接为官方的安装方法(官方的是最好的): https://docs.docker.com/install/linux/docker-ce/centos/#upgrade-docker-after- ...

  6. docker 安装centos7并SSH远程连接

    1.安装centos7 镜像 1.搜索并拉取centos镜像(默认最新镜像) docker search centos docker pull centos 2.建立本机对应docker-centos ...

  7. LANMP系列教程之php编译安装CentOS7环境

    前提:必须先安装好MySQL以及Apache   1.准备好源码包并配置好yum源,需要的源码包包括: libmcrypt-2.5.8-9.el6.x86_64.rpm libmcrypt-devel ...

  8. docker安装tensorflow环境遇到的问题与解决方案

    docker安装 Tensorflow遇到问题i/o timeout. docker: Error response from daemon: Get https://gcr.io/v1/_ping: ...

  9. Docker安装开发环境

    目录 Docker Docker 安装 Mysql Docker 安装Redis Docker 安装Zookeeper Docker Docker 安装 Mysql Docker 查看可用Mysql镜 ...

随机推荐

  1. 003、Java的单行注释

    代码如下: package TIANPAN; public class TestDemo { public static void main(String args[]) { // JAVA的单行注释 ...

  2. 7.6 CLI 管理Varnish

    ./varnishd -f /usr/common/varnish/etc/varnish/ -a 测试: 代理tomcat服务器地址:http://172.20.10.5:1111/ telnet ...

  3. 移动 web 开发问题和优化小结

    1.前言 到目前为止,互联网行业里,手机越来越智能化,移动端占有的比例越来越高,尤其实在电商,新闻,广告,游戏领域.用户要求越来越高,网站功能越来越好,效果越来越炫酷,这就要求我们产品质量越来越高,w ...

  4. vue数据变化后页面刷新

    在测试methods和conputed区别的时候,我在methods方法体内增加了一个vue数据自增语句,类似于this.abc++;导致整个页面无法加载出来. 原因是this.abc改变 会触发页面 ...

  5. 洛谷 P3205 [HNOI2010]合唱队(区间dp)

    传送门 解题思路 观察队形的组成方式可以得出,最后一名加入区间i...j的人要么是在i位置上,要么是在j位置上,所以我们可以用dp[i][j][0]表示区间i...j最后一个加入的人站在i位置上的方案 ...

  6. P1053 住房空置率

    P1053 住房空置率 转跳点:

  7. POJ 2142:The Balance

    The Balance Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4781   Accepted: 2092 Descr ...

  8. postman带上token对接口进行测试

    根据验证码进行登陆,登录之后返回token.然后请求其他接口时在header头中带上token访问其他接口进行测试 账户信息输入验证码 登陆成功,看到返回的token 我们这个项目可以刷新一下toke ...

  9. springboot#interceptor

    _ 拦截器相对与过滤器Filter 而言,拦截器是spring中的概念.过滤器是servlet中的概念.在spring中肯定是优先使用拦截器Interceptor的. public class My1 ...

  10. 101-PHP二维数组的元素输出三,封装成函数

    <?php $arr=array(array(76,87,68), array(65,89,95), array(90,80,66), array(90,95,65),5,234,56,'Hel ...