admin管理员组

文章数量:1649146

##注:本文主要参考官方文档、docker问答录而来,本人刚开始接触docker,再加上英语是没过4级的渣,可能翻译上有误,如有不对的地方请指出,谢谢。

安装前准备

了解docker

2017年3月docker官方将docker分为docker-ce(社区版)和docker-ee(企业版)。docker-ee可以免费试用一个月,然后就开始收费;docker-ce可以永久免费使用。docker-ee需要linux内核3.10及以上。

docker-ee拥有docker-ce能获得的所有服务,运行的是更稳定的、受到商业支持的docker引擎版本,能够使用docker官方提供的docker 数据中心管理的软件(安全),能够使用Universal Control  工具来管理应用的方方面面,使用docker信任、运行的一个私有的docker镜像长裤,使用docker信任、签署的生产镜像。
docker-ee和docker-ce比,docker-ee更稳定(不明显),更安全,更安全,更安全!

下图是阿里云docker介绍的一张图

docker支持与收费信息

只有docker-ce支持win10和苹果系统(建议不要在windows上玩)

docker-ce和docker-ee都支持微软云和亚马逊云

docker-ee支持的系统更多

docker-EE更加安全

Safer Applications with Docker EE
Security is not static. Modern apps are dynamic and requires a security model that is defined for the app and not tied to infrastructure. Docker EE provides an integrated security framework that provides stronger default security with the flexibility to change configurations and standardized interfaces for developers and IT to easily collaborate. From securing the environment, the communications and the apps themselves, Docker EE delivers safer apps for the enterprise.

开始安装

安装docker-ee请看官方文档

安装docker-ce

使用主机信息

hostnameIPsystem
repository192.168.233.159redhaat 7.4

关闭firewalld和selinux(临时关闭)
systemctl stop firewalld
setenforce 0

按照官方文档一步一步来吧
建议不要使用root运行docker(为了安全,手动滑稽)
删除老的docker

 yum remove docker \
                  docker-common \
                  docker-selinux \
                  docker-engine

安装yum管理工具

yum install -y yum-utils \
   device-mapper-persistent-data \
   lvm2

加载阿里提供的yum源文件

yum-config-manager \
     --add-repo \
     http://mirrors.aliyun/docker-ce/linux/centos/docker-ce.repo

重装一次发现阿里的yrepo文件是空的.....

那就自己临时写个吧
cat > /etc/yum.repos.d/docker-ce.repo << EOF
[docker-ce-stable]
name=Docker CE Stable - \$basearch
baseurl=http://mirrors.aliyun/docker-ce/linux/centos/7/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun/docker-ce/linux/centos/gpg
EOF

启用yum中的edge 和test源,默认是禁止的,也可以手动修改repo文件(没有特别要求建议不开)

yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test

重新加载yum缓存

yum clean all && yum makecache fast && yum repolist enabled

查看docker-ce下的安装包

yum list docker-ce --showduplicates | sort -r

这是没开test和edge的

这是开了test和edge的

要不要开自己选择

yum安装docker-ce(建议安装最新版本低一个版本的)

yum install -y docker-ce-17.12.0.ce

解释一下 docker-ce-17.12.0.ce
docker-ce是包名,
17.12.0.ce是版本号

云阿里的源就不会出现安装半天都装不上去的情况了

创建/etc/docker/daemon.json文件(没有启动会报错)
mkdir -p /etc/docker/
echo {} > /etc/docker/daemon.json
这里的{}表示所有为默认
daemon.json文件中可以设置加速器、storage-driver等

启动docker

systemctl start docker

查看状态

systemctl status docker

运行一个docker容器看看

docker run hello-world
说说上面这个命令吧。docker run hello-world是运行镜像,默认标签是latest,运行是docker会检查本地是否有该镜像,如果有就运行,如果没有就去镜像仓库找。在镜像仓库知道镜像后就会pull到本地,然后运行该镜像。

运行成功会返回这样一个信息

设置docker开启自启动

systemctl enable docker

删除docker-ce

yum remove docker-ce
rm -rf /var/lib/docker

docker使用端口

端口作用
2377/tcp用来初始化swarm和向swarm添加节点的
2376/tcpdocker-machine守护进程使用端口
2375/tcpdocker swarm管理端口,要小心使用!!
7946/{tcp,udp}docker守护进程的控制端口
4789/{tcp,udp}docker守护进程的控制端口
3375/tcp
3376/tcp

加速器

mkdir -p /etc/docker
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://s4fmn1e8.mirror.aliyuncs"],
    "debug" : true,
    "experimental" : true
}
EOF

重启docker监听不关闭容器
"live-restore": true,

参考

官方文档
docker问答录
docker容器网络通信原理

转载于:https://blog.51cto/13323775/2055383

本文标签: DockerCE