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:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker Hub account:https://hub.docker.comFor 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:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7Hello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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 ~]# 

转载于:https://www.cnblogs.com/anliven/p/6202083.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/259905.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HDU 1715 大菲波数 (大数问题)

/* 复习大数问题&#xff1b; */ #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> #include <iomanip> using namespace std;int nu…

springcloud 相同服务名_SpringCloud系列之SpringCloud Stream

SpringCloud Stream技术兴起的原因&#xff1a;为了解决系统中不同中间件的适配问题&#xff0c;出现了cloud stream&#xff0c;采用适配绑定的方式&#xff0c;自动给不同的MQ之间进行切换。屏蔽底层消息中间件的差异&#xff0c;降低切换成本&#xff0c;统一消息的编程模型…

计算机意外重启或遇错误无法继续,计算机意外地重新启动或遇到错误如何解决?...

电脑小白在重装系统后难免会遇到些问题&#xff0c;有的容易处理&#xff0c;有的会有些棘手。那么&#xff0c;计算机意外地重新启动或遇到错误如何解决?今天快启动小编为大家分享详细的计算机意外地重新启动或遇到错误的解决方法&#xff0c;献给对系统重装知识不太了解的小…

jqueryui的Tooltip使用方法

http://api.jqueryui.com/tooltip/#option-position&#xff0c;详细使用方法。 http://jqueryui.com/tooltip/&#xff0c;DEMO。 content使用 $( ".selector" ).tooltip({ content: "Awesome title!" });//div及相关标签使用样式&#xff0c;鼠标放上去时…

iOS 开发者账号共用发布证书 (Distribution)问题

苹果客服回复&#xff1a; 1.第一台申请发布证书的电脑&#xff0c;从钥匙串中导出发布证书(Distribution)颁发的request文件&#xff1f;然后在第二台电脑上用request文件新生成一个Distribution证书&#xff0c;这个是可以共用的&#xff1f;&#xff08;不理解还是理解错了&…

JMeter web 测试

2019独角兽企业重金招聘Python工程师标准>>> JMeter web 测试 http://jmeter.apache.org/usermanual/build-web-test-plan.html 转载于:https://my.oschina.net/276172622/blog/808957

scala 连接oracle_一分钟教你学会用java连接Oracle数据库

package java_jdbc;//java连接Oracle数据库import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;public class JdbcOracleTest {public static void main(String[] args) {// TODO Auto-generated method stub//1.…

计算机软件记不住设置,想知道电脑密码记不住了怎么办

635509517回答数&#xff1a;23216 | 被采纳数&#xff1a;32017-01-09 17:51:10方法一&#xff1a;(1)启动电脑&#xff0c;使用DOS启动盘(比如&#xff1a;Windows 98启动盘)进入纯DOS状态。(2)在DOS提示符下&#xff0c;根据下面步骤操作&#xff1a;cd\\ (切换到根目录)c…

vue-cli#2.0 webpack 配置分析

目录结构&#xff1a; ├── README.md ├── build │ ├── build.js │ ├── check-versions.js │ ├── dev-client.js │ ├── dev-server.js │ ├── utils.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js…

initWithNibName与viewDidLoad的执行关系以及顺序

一个ViewController&#xff0c;一般通过init或initWithNibName来加载。二者没有什么不同&#xff0c;init最终还是要调用initWithNibName方法&#xff08;除非这个ViewController没有nib文件&#xff09;。 我们经常在initWithNibName方法中初始化视图&#xff0c;变量或者其他…

120xa正反转参数_你知道变频器的“正反转死区时间”吗?它的“停机方式”有几种?...

若你我之间有缘&#xff0c;关注作者又何妨&#xff1f;两情若是久长时&#xff0c;又岂在朝朝暮暮。大家好&#xff01;我是江郎&#xff0c;一个踏踏实实的维修工。本期我们仍然探讨两个问题&#xff0c;如标题所述&#xff0c;#变频器#“死区时间”和“停机方式”&#xff0…

【转】游戏编程中的人工智能技术--神经网络

原文&#xff1a;http://blog.csdn.net/ecitnet/article/details/1799444 游戏编程中的人工智能技术.>. (连载之一)用平常语言介绍神经网络(Neural Networks in Plain English)因为我们没有很好了解大脑&#xff0c;我们经常试图用最新的技术作为一种模型来解释它。在我童年…

w8计算机配置要求,win8系统最低配置要求有哪些|win8系统是否有最低配置要求-系统城...

2013-10-17 17:08:08  浏览量&#xff1a;5753小编这里要为大家带来的是win8系统最低配置要求和部分安装截图&#xff0c;很多用户想要将自己的电脑装上win8&#xff0c;但也不是每一台电脑都可以安装win8系统的&#xff0c;为了避免一些低配置的用户安装了win8之后却无法运行…

Session 丢失问题

项目从.NET Framework3.5 升级 .NET Framework4.0后&#xff0c;如果用Response.Redirect();进行页面的跳转&#xff0c;服务端会把这个跳转动作当作是一个“新”的用户去访问网页。 而这个时候&#xff0c;会给这个“新”的用户一个SessionID&#xff0c;那造成的结果是&#…

财务管理专业应该报计算机二级哪个科目,我是应该报计算机二级还是三级呢

2008-12-01怎样学好财务管理&#xff1f;“五步”学好财务管理:学习这门课程前&#xff0c;首先就不要认为它“很难”&#xff0c;只要相信“难而不会&#xff0c;会而不难”&#xff0c;充满信心一定就能学好。我在学习过程中总结了几条经验&#xff0c;以供各位学友参考&…

libsvm java 调用说明

libsvm是著名的SVM开源组件&#xff0c;目前有JAVA.C/C,.NET 等多个版本&#xff0c;本人使用的是2.9libsvm命名空间下主要使用类&#xff1a;svm_model 为模型类&#xff0c;通过训练或加载训练好的模型文件获得svm_parameter 为参数类&#xff0c;主要为支持向量机设定参数&a…

java字符串排序_对字符串排序持一种宽容的心态

在Java中一涉及中文处理就会冒出很多问题来&#xff0c;其中排序也是一个让人头疼的课题&#xff0c;我们来看下面的代码&#xff1a;上面的代码定义一个数组&#xff0c;然后进行升序排序&#xff0c;我们期望的结果是按照拼音升序排列&#xff0c;即为李四、王五、张三&#…

rails开发随手记-0

helper默认是只在view中可用的&#xff0c;如果在controller中也要使用&#xff0c;要在ApplicationController中 include 如果model中如果有叫做type的列的话&#xff0c;会触发rails的Single Table Inheritance &#xff0c;放弃它吧&#xff0c;不好用&#xff0c;还是安心使…

nagios 监控配置介绍(二)

#配置服务端监控客户端[rootnagios etc]# cd objects/[rootnagios objects]# vi hosts.cfg# Define a host for the local machinedefine host{use linux-serverhost_name 1.3-sambaalias 1.3-sambaaddress …