download and install
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.14-3.el7.x86_64.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.14-3.el7.x86_64.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.3.9-3.1.el7.x86_64.rpm
yum localinstall -y docker-ce-cli-19.03.14-3.el7.x86_64.rpm
yum localinstall -y containerd.io-1.3.9-3.1.el7.x86_64.rpm
yum localinstall -y docker-ce-19.03.14-3.el7.x86_64.rpm
configure
Proxy settings for Docker daemon
mkdir -p /etc/systemd/system/docker.service.d
Create a file named /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80"
Environment="HTTPS_PROXY=https://proxy.example.com:443"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
Save the file.
Proxy settings for Docker Container
Refer to my blog: https://blog.csdn.net/zhixingheyi_tian/article/details/110482646
也就是配置这个
~/.docker/config.json
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:3001",
"httpsProxy": "http://127.0.0.1:3001",
"noProxy": "*.test.example.com,.example2.com"
}
}
}
修改 data location
默认存储路径为 /var/lib/docker
service docker stop
vi /etc/docker/daemon.json
{
"data-root": "/home/lib/docker"
}
systemctl restart docker
使用 docker info 检查
# docker info | grep "Docker Root Dir"
Docker Root Dir: /home/lib/docker
Enable configs and verify
Refer to my blog:
https://blog.csdn.net/zhixingheyi_tian/article/details/89374623
Issues Resolving
# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid.
See 'docker run --help'.
如遇到如上问题,可能是Linux 系统时间没有校正
# date --set="Wed 2020-12-23 16:06:06 CST"
Wed Dec 23 16:06:06 CST 2020
# timedatectl
Local time: Wed 2020-12-23 16:06:08 CST
Universal time: Wed 2020-12-23 08:06:08 UTC
RTC time: Tue 2015-01-13 07:05:02
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
遇到以下问题,
删除docker 存储目录, 重启 docker 服务
# docker build --tag test/centos8:env-0.1 -f ./scripts/centos-8-stream.dockerfile .
Sending build context to Docker daemon 84.28MB
Step 1/4 : FROM quay.io/centos/centos:stream8
stream8: Pulling from centos/centos
6c5de04c936d: Already exists
f1ee40d9db4a: Already exists
17facd475902: Already exists
0d557d32f54e: Already exists
Digest: sha256:c9acf46f90fcb637eff59e269fbbebf5ec9e6b6215a07fbe2bbad7429aad6e7e
Status: Downloaded newer image for quay.io/centos/centos:stream8
---> 660b13416363
Step 2/4 : ADD scripts /velox/scripts/
failed to create rwlayer: open /home/lib/docker/overlay2/e50c79574832a05cb741600f138d0120762db8cb86439219f3a3019a0d0e350c/committed: no such file or directory