这些天研究了下docker,在centos6.6上装了个docker1.7.1,在centos7.6上装了个docker18.09.0

  两者还是有区别的。

  1.配置docker国内镜像加速

   Docker的1.7.1版本Docker配置文件在/etc/sysconfig/docker下,1.8或者1.10等更高版本在/etc/docker/daemon.json 
  docker 1.7配置如下 

# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d other_args="--registry-mirror=https://yvaq2qqy.mirror.aliyuncs.com" #OPTIONS='--registry-mirror=https://yvaq2qqy.mirror.aliyuncs.com' DOCKER_CERT_PATH=/etc/docker # Resolves: rhbz#1176302 (docker issue #407)
DOCKER_NOWARN_KERNEL_VERSION=1 # Location used for temporary files, such as those created by
# # docker load and build operations. Default is /var/lib/docker/tmp
# # Can be overriden by setting the following environment variable.
# # DOCKER_TMPDIR=/var/tmp

  之后service docker restart。并查看进程,发现已经改掉。

[root@localhost docker]# ps -ef|grep docker
root 2746 1 0 06:25 pts/0 00:00:00 /usr/bin/docker -d --registry-mirror=https://yvaq2qqy.mirror.aliyuncs.com
root 2790 1665 0 06:25 pts/0 00:00:00 grep docker

  更高docker版本配置

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://yvaq2qqy.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

  

  之后用docker info验证

[root@localhost docker]# docker info
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 2
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.1.3.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 991.2MiB
Name: localhost.localdomain
ID: H3P2:25SP:CIQM:G5V5:VWFZ:2ENN:YGO5:JDAA:NSVJ:BEPY:EPZK:J4QE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:  #这个配置已生效
https://yvaq2qqy.mirror.aliyuncs.com/
Live Restore Enabled: false
Product License: Community Engine

  2.CentOS7中关闭firewall,并使用iptables管理防火墙

  下载完镜像后,启动时候,竟然出现如下错误。

[root@localhost ~]# docker run -d -P training/webapp python app.py
29cd64c0c282439d8fd6883f29d6a3a23cbef00bd0256ffb9e81561562ed0f5b
docker: Error response from daemon: driver failed programming external connectivity on endpoint laughing_austin
(e1b9e047d2e915fa77730e8d0e1c6c007a6034bcc782a441934b28ee91058256):
(COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -A DOCKER -p tcp -d 0/0 --dport 32787 -j DNAT --to-destination 172.17.0.2:5000 ! -i docker0'
failed: iptables: No chain/target/match by that name.
).

  经研究下,是防火墙的缘故。

  在使用Docker时,启用centos7默认的firewall,启动端口映射时,防火墙规则不生效。docker默认使用了iptables防火墙机制。所以需要关闭firewall使用iptables解决。

  ①关闭默认firewall防火墙

systemctl stop firewalld.service 关闭防火墙

systemctl disable firewalld.service 关闭开机启动

  ②开启iptables

yum install iptables (根据centOS7的版本和内核,有些版本已经装过,可以跳过此命令)
yum install iptables-services
service iptables restart
chkconfig iptables on
或者
systemctl enable iptables.service 开机自启

  ③添加防火墙命令

/sbin/iptables -I INPUT -p tcp --dport  -j ACCEPT   添加防火墙规则
iptables -L -n 查看防火墙的设置情况

  上述步骤执行完成之后,docker运行该容器就能成功了。

docker 在centos6 和centos7上的区别的更多相关文章

  1. 如何在centos6和centos7上部署nfs共享服务器和客户端

    nfs共享服务为中小型企业在存储上提供了有效的节省空间,许多大型的网站也在使用nfs,如百度和阿里等,下面结合自己所学的知识,阐述如何在centos6和centos7下配置nfs.注:除了必要的说明外 ...

  2. CentOS6与CentOS7的网络区别

    回顾:物理层 关注的是接口物理特性,传输介质数据链路层 MAC地址,数据帧,以太网,交换机网络层 IP地址,数据包,IP\ICMP\ARP协议,路由器传输层 TCP.UDP,端口号,数据段应用层 HT ...

  3. 【docker】centOS7上部署的mysql和spring boot服务,要求,mysql的时间、java程序服务的时间和宿主机的时间完全保持一致【修改mysql时区,临时和永久】【修改spring boot配置文件时区】【修改docker启动spring boot实例程序时区】

    要求:centOS7上部署的mysql和spring boot服务,要求,mysql的时间.java程序服务的时间和宿主机的时间完全保持一致: ============================ ...

  4. centos7上docker安装和使用教程

    Docker 是一个创建和管理 Linux 容器的开源工具.容器就像是轻量级的虚拟机,并且可以以毫秒级的速度来启动或停止.Docker 帮助系统管理员和程序员在容器中开发应用程序,并且可以扩展到成千上 ...

  5. centos7上安装docker社区版

    container(容器) docker(集装箱) 容器的优点 1. 启动速度快 2. 节省资源 3. 兼容性高 保证机器正常上网 #ping www.baidu.com CPU需要支持虚拟化 # g ...

  6. 2、centos6和centos7的区别

    services使用了systemd来代替sysvinit管理. systemd是Linux下的一种init软件,由Lennart Poettering带头开发,并在LGPL 2.1及其后续版本许可证 ...

  7. Docker实践(6)—CentOS7上部署Kubernetes

    Kubernetes架构 Kubernetes的整体架构如下: Master为主控节点,上面运行apiserver,scheduler,controller-manager等组件.Minion相当于工 ...

  8. Centos7上安装docker (转)

    Centos7上安装docker Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如 ...

  9. 配置 Docker 加速器:适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1

    天下容器, 唯快不破 Docker Hub 提供众多镜像,你可以从中自由下载数十万计的免费应用镜像, 这些镜像作为 docker 生态圈的基石,是我们使用和学习 docker 不可或缺的资源.为了解决 ...

随机推荐

  1. MySQL高可用复制管理工具 —— Orchestrator介绍

    背景 在MySQL高可用架构中,目前使用比较多的是Percona的PXC,Galera以及MySQL 5.7之后的MGR等,其他的还有的MHA,今天介绍另一个比较好用的MySQL高可用复制管理工具:O ...

  2. Uncaught SyntaxError: Invalid shorthand property initializer报错

    出现这个错误一定是:把":"写成了"="号

  3. C#在截屏时将截屏之前需要隐藏的控件也截入

    最近我在项目中遇到一个让我十分头疼的问题,就是我在截屏时也将截屏之前隐藏的控件也截入了. 情况:我在Winform窗体有个截屏功能按钮,实现在调用WPF全屏后截屏,但在截屏WPF界面前将界面里的一个L ...

  4. Spring Boot 整合 docker

    一.什么是docker ? 简介 Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs ...

  5. vue2.x 时间范围 date range timepicker。只在项目中使用elementUI的date-picker

    elementUI官方案例:http://element.eleme.io/#/zh-CN/component/date-picker (1)效果图: (2)安装和引入 npm i element-u ...

  6. JavaScript类型化数组(二进制数组)

    0.前言 对于前端程序员来说,平时很少和二进制数据打交道,所以基本上用不到ArrayBuffer,大家对它很陌生,但是在使用WebGL的时候,ArrayBuffer无处不在.浏览器通过WebGL和显卡 ...

  7. Docker入门笔记

    Docker入门笔记 随笔记录初学Docker遇到的问题, 以免下次再犯. 本机系统Ubuntu18.04 安装 Docker有2个版本 Community Edition (CE) 社区版(免费) ...

  8. MongoDB分片 在部署和维护管理 中常见事项的总结

    分片(sharding)是MongoDB将大型集合分割到不同服务器(或者说集群)上所采用的方法,主要为应对高吞吐量与大数据量的应用场景提供了方法. 和既有的分库分表.分区方案相比,MongoDB的最大 ...

  9. 基础学习14天 MD5加密

    private static string GetMD5(string str) { //创建MD5对象 MD5 md5 = MD5.Create(); //字符串类型转换Wie字节 byte[] b ...

  10. iOS开发之OC与swift开发混编教程,代理的相互调用,block的实现。OC调用Swift中的代理, OC调用Swift中的Block 闭包

    本文章将从两个方向分别介绍 OC 与 swift 混编 1. 第一个方向从 swift工程 中引入 oc类 1. 1 如何在swift的类中使用oc类    1.2  如何在swift中实现oc的代理 ...