【笔记】Docker
linux 7.0以上版本
一、docker
CentOS7升级最新版本Docker
首先升级一下系统包 (可以跳过)
$ sudo yum update
卸载旧版本的 Docker
$ sudo yum erase docker docker-common docker-client docker-compose
添加 Docker 的 yum 源
创建一个 /etc/yum.repos.d/docker.repo 文件,内容如下:
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
安装新版本 Docker
$ sudo yum install -y docker-engine
安装完后设置为系统开机自动启动服务
$ sudo systemctl enable docker.service
启动服务
$ sudo systemctl start docker
测试一下
docker info
# docker -v
Docker version 17.05.0-ce, build 89658be
# /bin/systemctl start docker.service
二、docker-compose
# sudo curl -L https://github.com/docker/compose/releases/download/1.21.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
问题1:
curl: (35) Peer reports incompatible or unsupported protocol version.
处理1:
# yum update -y nss curl libcurl
问题2:
curl: (35) SSL connect error
处理2:
# yum -y update nss
问题3 在非root账户下面执行
$ docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
解决3
# ll /var/run/docker.sock
srw-rw---- 1 root docker 0 Feb 13 16:38 /var/run/docker.sock
# chmod 666 /var/run/docker.sock
# chmod +x /usr/local/bin/docker-compose
# docker-compose -v
docker-compose version 1.21.1, build 5a3f1a3