一千萬個為什麽

搜索

無法在Ubuntu 16.04上更改Docker大小



Docker版本18.03.1-ce,build 9ee9f40

我正在嘗試增加Ubuntu 16.04上的docker容器大小。

I have created the following file at /etc/docker/daemon.json

{
    "storage-opts": ["dm.basesize=20G"]
}

However when I sudo service docker start I get: Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

如果我刪除 /etc/docker/daemon.json ,那麽docker就可以啟動了。

檢查推薦的日誌產生

systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Sat 2018-05-05 12:58:26 PDT; 4min 35s ago
     Docs: https://docs.docker.com
  Process: 3047 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=1/FAILURE)
 Main PID: 3047 (code=exited, status=1/FAILURE)

May 05 12:58:26 stage systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
May 05 12:58:26 stage systemd[1]: Failed to start Docker Application Container Engine.
May 05 12:58:26 stage systemd[1]: docker.service: Unit entered failed state.
May 05 12:58:26 stage systemd[1]: docker.service: Failed with result 'exit-code'.
May 05 12:58:26 stage systemd[1]: docker.service: Service hold-off time over, scheduling restart.
May 05 12:58:26 stage systemd[1]: Stopped Docker Application Container Engine.
May 05 12:58:26 stage systemd[1]: docker.service: Start request repeated too quickly.
May 05 12:58:26 stage systemd[1]: Failed to start Docker Application Container Engine.

journalctl -xe
--
-- Unit docker.socket has begun starting up.
May 05 12:58:26 stage systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has finished starting up.
--
-- The start-up result is done.
May 05 12:58:26 stage systemd[1]: docker.service: Start request repeated too quickly.
May 05 12:58:26 stage 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.
--
-- The result is failed.
May 05 12:58:26 stage systemd[1]: docker.socket: Unit entered failed state.
May 05 13:01:16 stage sudo[3069]:      mjb : TTY=pts/0 ; PWD=/var/www/app ; USER=root ; COMMAND=/bin/cat /etc/docker/daemon.json
May 05 13:01:16 stage sudo[3069]: pam_unix(sudo:session): session opened for user root by mjb(uid=0)
May 05 13:01:16 stage sudo[3069]: pam_unix(sudo:session): session closed for user root

如何在Ubuntu上增加Docker的默認 dm.basesize ,這樣,當我使用命令 sudo service docker start 啟動docker時,它會啟動並增加 dm.basesize </代碼>?

轉載註明原文: 無法在Ubuntu 16.04上更改Docker大小

一共有 2 個回答:

唯一的日誌消息是“開始請求重復得太快”。所以我們錯過了錯誤的開始。您可以以root systemctl reset-failed 然後 systemctl start docker 然後 journalctl -u docker --no-pager -n 50 運行顯示最後50行日誌。

最有可能的問題是,您的存儲驅動程序不是設備映射器,此選項僅適用於設備映射器。在18.03安裝上,ubuntu將使用最新的內核覆蓋2,或者可能是舊內核上的aufs。如果不使用設備映射器存儲驅動程序,則不應設置該選項。

你可以在/etc/docker/daemon.json下面試試

{
    "experimental" : true,
    "storage-driver" : "devicemapper",
    "storage-opts" : ["dm.basesize=20G"]
}

然後嘗試:

systemctl daemon-reload
systemctl restart docker