centos7.5 docker


查看linux版本
$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)
更新yum
$ yum update
安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
$ yum install -y yum-utils device-mapper-persistent-data lvm2
添加源
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
查看所有安装包,由于repo中默认只开启stable仓库,故这里安装的是最新稳定版 18.06.0.ce
$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable

安装docker,yum install docker-ce-加上版本号,例如:18.03.0.ce
$ yum install docker-ce-18.03.0.ce
关闭防火墙
$ systemctl stop firewalld.service
禁止防火墙开机启动
$ systemctl disable firewalld.service
启动并加入开机启动
$ systemctl start docker
$ systemctl enable docker
验证安装是否成功(有client和service两部分表示docker安装启动都成功了)
$ docker version
Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:09:15 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:13:03 2018
  OS/Arch:  linux/amd64
  Experimental: false
镜像加速 详见阿里云开发者平台
配置日志大小限制
1.新建/etc/docker/daemon.json,若有就不用新建了。添加log-dirver和log-opts参数,样例如下:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://3o6lhri3.mirror.aliyuncs.com"],
  "log-driver":"json-file",
  "log-opts": {"max-size":"50m", "max-file":"5"}
}
EOF
sudo systemctl daemon-reload & systemctl restart docker
2.然后重启docker的守护线程
$ systemctl daemon-reload && systemctl restart docker

你可能感兴趣的:(centos7.5 docker)