s
問題3
[root@centos7 ~]# vim /etc/docker/daemon.json
{
"graph":"/home/lab/docker/store",
"storage-driver": "overlay2"
}
[root@centos7 ~]# docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@centos7 docker]# ls /etc/docker/
certs.d key.json seccomp.json daemon.json
[root@centos7 docker]# systemctl restart docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
解決3
[root@centos7 docker]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-08-19 10:51:57 CST; 1min 2s ago
Docs: http://docs.docker.com
Process: 3504 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 3504 (code=exited, status=1/FAILURE)
Aug 19 10:51:57 centos7 systemd[1]: Starting Docker Application Container Engine...
Aug 19 10:51:57 centos7 dockerd-current[3504]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: archMap, s... defaultAction
Aug 19 10:51:57 centos7 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 19 10:51:57 centos7 systemd[1]: Failed to start Docker Application Container Engine.
Aug 19 10:51:57 centos7 systemd[1]: Unit docker.service entered failed state.
Aug 19 10:51:57 centos7 systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos7 docker]# journalctl -xe
-- Unit docker.service has begun starting up.
Aug 19 09:53:04 centos7 dockerd-current[29211]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: grap
Aug 19 09:53:04 centos7 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 19 09:53:04 centos7 systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
原因:自定義/etc/docker/daemon.json 中 含有--graph=/xxxx 的自定義存儲路徑與 /etc/sysconfig/docker 中 參數--graph=/home/lab/docker/images 存儲地址沖突導致。
Docker(十六)-Docker的daemon.json的作用
https://www.cnblogs.com/zhuochong/p/10070434.html
[root@centos7 ~]# rm -f /etc/docker/daemon.json
[root@centos7 ~]# systemctl restart docker.service
[root@centos7 store]# docker -v
Docker version 1.13.1, build 64e9980/1.13.1
Docker修改默認存儲位置(轉)
https://www.cnblogs.com/flying607/p/9283003.html
https://blog.51cto.com/forangela/1949947
方法一、軟鏈接
默認情況下Docker的存放位置為:/var/lib/docker
可以通過下面命令查看具體位置:
sudo docker info | grep "Docker Root Dir"
解決這個問題,最直接的方法當然是掛載分區到這個目錄,但是我的數據盤還有其他東西,這肯定不好管理,所以采用修改鏡像和容器的存放路徑的方式達到目的。
這個方法里將通過軟連接來實現。
首先停掉Docker服務:
systemctl restart docker或者service docker stop
然后移動整個/var/lib/docker目錄到目的路徑:
mv /var/lib/docker /root/data/dockerln -s /root/data/docker /var/lib/docker
這時候啟動Docker時發現存儲目錄依舊是/var/lib/docker,但是實際上是存儲在數據盤的,你可以在數據盤上看到容量變化。
方法二、修改鏡像和容器的存放路徑
指定鏡像和容器存放路徑的參數是--graph=/var/lib/docker,我們只需要修改配置文件指定啟動參數即可。
Docker 的配置文件可以設置大部分的后台進程參數,在各個操作系統中的存放位置不一致,在 Ubuntu 中的位置是:/etc/default/docker,在 CentOS 中的位置是:/etc/sysconfig/docker。
如果是 CentOS6 則添加下面這行:
OPTIONS=--graph="/root/data/docker" --selinux-enabled -H fd://
如果是 Ubuntu 則添加下面這行(因為 Ubuntu 默認沒開啟 selinux):
OPTIONS=--graph="/root/data/docker" -H fd://# 或者DOCKER_OPTS="-g /root/data/docker"
最后重新啟動,Docker 的路徑就改成 /root/data/docker 了。
centos7下,也可以
修改docker.service文件,使用-g參數指定存儲位置
vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --graph /new-path/docker
// reload配置文件
systemctl daemon-reload
// 重啟docker
systemctl restart docker.service
如果docker是1.12或以上的版本,可以修改(或新建)daemon.json文件。修改后會立即生效,不需重啟docker服務。
vim /etc/docker/daemon.json
{"registry-mirrors": ["http://7e61f7f9.m.daocloud.io"],"graph": "/new-path/docker"}
方法三、system下創建配置文件
在/etc/systemd/system/docker.service.d 目錄下創建一個Drop-In文件“docker.conf”,默認 docker.service.d 文件夾不存在。所以你必須先創建它。
創建Drop-In 文件的原因,是我們希望Docker 服務,使用docker.conf文件中提到的特定參數,將默認服務所使用的位於/lib/systemd/system/docker.service文件中的參數進行覆蓋。如果你想深入了解Drop-In,請閱讀system.unit文檔
定義新的存儲位置現在打開docker.conf增加如下內容:
# sudo vi /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --graph="/mnt/new_volume" --storage-driver=devicemapper
保存並退出VI編輯器,/mnt/new_volume 是新的存儲位置,而devicemapper是當前docker所使用的存儲驅動。如果你的存儲驅動有所不同,請輸入之前第一步查看並記下的值。Docker官方文檔中提供了更多有關各種存儲驅動器的信息。現在,你可以重新加載服務守護程序,並啟動Docker服務了。這將改變新的鏡像和容器的存儲位置。
# sudo systemctl daemon-reload
# sudo systemctl start docker
為了確認一切順利,運行 # docker info 命令檢查Docker 的根目錄.它將被更改為/mnt/new_volume
方法四、使用docker-storage-set(docker1.12)命令進行配置
配置文件位置:/usr/lib/docker-storage-setup/docker-storage-setup或者/etc/sysconfig/docker-storage-setup、/etc/sysconfig/docker-storage
vim /etc/sysconfig/docker-storage
# This file may be automatically generated by an installation program.
# Please DO NOT edit this file directly. Instead edit
# /etc/sysconfig/docker-storage-setup and/or refer to
# "man docker-storage-setup".
# By default, Docker uses a loopback-mounted sparse file in
# /var/lib/docker. The loopback makes it slower, and there are some
# restrictive defaults, such as 100GB max storage.
DOCKER_STORAGE_OPTIONS=--graph="要保存的路徑"
或者
DEVS=/dev/vdb
DATA_SIZE=800GB(更改docker默認存儲大小)
end