Docker - 在CentOS 7中安装Docker
在CentOS 7中安装Docker
1-确认系统信息
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# uname -a
Linux CentOS-7 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2-安装docker
# yum -y install docker
3-关闭SELinux和启动docker服务
关闭SELinux
- 永久方法:修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启。
- 临时方法:执行
setenforce 0命令设置SELinux成为permissive模式
sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
启动docker服务
[root@CentOS-7 ~]# systemctl start docker.service
设置自启动docker服务
[root@CentOS-7 ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@CentOS-7 ~]# systemctl is-enabled docker.service
enabled
[root@CentOS-7 ~]#
4-设置docker代理
# vim /etc/sysconfig/docker
根据实际需要添加相应内容
HTTP_PROXY=http://10.144.1.10:8080
#HTTPS_PROXY=https://10.144.1.10:8080
#FTP_PROXY=ftp://10.144.1.10:8080
注意:一般情况下,国内镜像设置或代理设置,只需要完成一种配置就可以了。
5-重启docker
# systemctl daemon-reload
# systemctl restart docker
6-安装验证
运行官方镜像hello-world文件
# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for docker.io/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/
#
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest c54a2cc56cbb 5 months ago 1.848 kB
另外一种Docker代理设置方法
修改docker.service文件
# vim /usr/lib/systemd/system/docker.service
在[Service]部分添加如下内容
Environment="HTTP_PROXY=http://10.144.1.10:8080"
Environment="HTTPS_PROXY=https://10.144.1.10:8080"
Environment="FTP_PROXY=ftp://10.144.1.10:8080"
或者,另外创建代理文件
# mkdir /etc/systemd/system/docker.service.d
# touch /etc/systemd/system/docker.service.d/proxy.conf
# vim /etc/systemd/system/docker.service.d/proxy.conf
增加以下内容
[Service]
Environment="HTTP_PROXY=http://10.144.1.10:8080"
Environment="HTTPS_PROXY=https://10.144.1.10:8080"
Environment="FTP_PROXY=ftp://10.144.1.10:8080"
重启docker
# systemctl daemon-reload
# systemctl restart docker
检查docker环境变量是否加载
# systemctl show docker --property Environment
Environment=GOTRACEBACK=crash HTTP_PROXY=http://10.144.1.10:8080 HTTPS_PROXY=https://10.144.1.10:8080 FTP_PROXY=ftp://10.144.1.10:8080
示例 - 在CentOS7系统安装docker并运行镜像(使用国内镜像)
[root@CentOS7 ~]# route add default gw 10.0.3.2
[root@CentOS7 ~]#
[root@CentOS7 ~]# yum -y install docker
[root@CentOS7 ~]# vim /etc/selinux/config
[root@CentOS7 ~]# cat /etc/selinux/config |grep "SELINUX="
# SELINUX= can take one of these three values:
SELINUX=disabled
[root@CentOS7 ~]#
[root@CentOS7 ~]# setenforce 0
[root@CentOS7 ~]#
[root@CentOS7 ~]# systemctl start docker.service
[root@CentOS7 ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@CentOS7 ~]# systemctl is-enabled docker.service
enabled
[root@CentOS7 ~]#
[root@CentOS7 ~]# sudo mkdir -p /etc/docker
[root@CentOS7 ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
}
[root@CentOS7 ~]# systemctl daemon-reload
[root@CentOS7 ~]# systemctl restart docker
[root@CentOS7 ~]#
[root@CentOS7 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@CentOS7 ~]#
[root@CentOS7 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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/
[root@CentOS7 ~]#
[root@CentOS7 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest 48b5124b2768 3 months ago 1.84 kB
[root@CentOS7 ~]#
Docker - 在CentOS 7中安装Docker的更多相关文章
- Docker 01 - CentOS 7 中安装 Docker 的详细步骤
目录 1 初识 Docker 1.1 Docker 原理简介 1.2 Docker 核心概念 2 安装 Docker 2.1 查看系统内核版本 2.2 更新 yum 包 2.3 安装软件包 2.4 向 ...
- docker~在centos容器中安装新程序
上一篇我们使用了阿里加速器安装了centos镜像,然后创建了一个新容器,运行了这个镜像,这一讲我们来为这个镜像添加一些应用程序,然后再保存容器,push容器到仓储,大家就可以直接pull我生产的容器了 ...
- [后端及服务器][WSL2(Ubuntu)+Docker]从零开始在WSL中安装Docker
目录 简介 WSL 安装 开启虚拟化(BIOS) 检查系统版本 安装WSL 老版本安装详情 简介 想花三篇文章写下从Windows(WSL)上开启Docker部署php/node/vue/html等项 ...
- Docker - 在Ubuntu16.04中安装Docker CE
Get Docker for Ubuntu Check system version root@Ubuntu16:~# uname -a Linux Ubuntu16 4.8.0-36-generic ...
- win7下docker环境centos容器中安装mysql5.7
docker环境基于镜像skiychan/nginx-php7,进行安装 ps:skiychan/nginx-php7此镜像已封装nginx1.15.3+php7.2.9 1.环境配置 配置共享文件夹 ...
- 在CentOS 7 中安装Docker
https://birdteam.net/135360 sudo systemctl enable docker sudo systemctl start docker
- Docker - 在CentOS7中安装Docker
在CentOS 7中安装Docker 1-确认系统信息 # cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # uname - ...
- 第二章、 Centos 6.8安装 Docker
2.1检查Docker的先决条件 64位 CPU计算机(x86_64),不支持32位 CPU 运行Linux 3.8 或更高版本内核. 内核必须支持一种合适的存储驱动(storage driver), ...
- Docker学习笔记之-在CentOS中安装Docker
上一节演示了如何 通过Xshell连接CentOS服务,链接:Docker学习笔记之-通过Xshell连接 CentOS服务 本节将演示 如何在CentOS中安装 Docker 第一步:更新系统包到最 ...
随机推荐
- Replication的犄角旮旯(八)-- 订阅与发布异构的问题
<Replication的犄角旮旯>系列导读 Replication的犄角旮旯(一)--变更订阅端表名的应用场景 Replication的犄角旮旯(二)--寻找订阅端丢失的记录 Repli ...
- Snmp协议应用-扫描局域网内打印机
.h2cls { background: #6fa833 none repeat scroll 0 0 !important; color: #fff; font-family: "微软雅黑 ...
- [.NET领域驱动设计实战系列]专题八:DDD案例:网上书店分布式消息队列和分布式缓存的实现
一.引言 在上一专题中,商家发货和用户确认收货功能引入了消息队列来实现的,引入消息队列的好处可以保证消息的顺序处理,并且具有良好的可扩展性.但是上一专题消息队列是基于内存中队列对象来实现,这样实现有一 ...
- 【腾讯Bugly干货分享】QFix探索之路—手Q热补丁轻量级方案
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57ff5832bb8fec206ce2185d 导语 QFix 是手Q团队近期推 ...
- 解决Win7 软件图标不显示--Win7图标异常,快捷方式不显示解决方法
电脑症状:WIN7的系统,桌面上的图标显示的不正常,快捷方式显示的是未知程序.看不到程序默认图标,快捷方式图标不显示. 解决方法:删除程序图标缓存即可. 将下面的内容复制到记事本保存为“Repai ...
- js函数实现转换css中常用的颜色编码
//转换css中常用颜色编码 var toRGB = function (val){ var reg1 = /^#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; ...
- MVC5:使用Ajax和HTML5实现文件上传功能
引言 在实际编程中,经常遇到实现文件上传并显示上传进度的功能,基于此目的,本文就为大家介绍不使用flash 或任何上传文件的插件来实现带有进度显示的文件上传功能. 基本功能:实现带有进度条的文件上传功 ...
- Linux网络编程系列-套接口选项控制
获取和设置套接口选项的方法有: getsockopt/setsockopt fcntl ioctl getsockopt/setsockopt 这两个函数仅用于套接口(socket)的设置,另外两个函 ...
- 关于session的小结
session的原理 Session对象的原理在于,服务器可以为客户端创建并维护一个所谓的Session对象,用于存放数据. 在创建Session对象的同时,服务器将会为该Session对象产生一个唯 ...
- Android开发学习之路-使用AsyncTask进行异步操作
通常情况下,我们要实现异步操作,也就是在子线程进行耗时操作比如下载或者加载图片等,然后在UI(主)线程中更新UI,使用的是Handler和Message来进行异步的实现,但是,谷歌官方在Android ...