通過二進位制安裝的 Docker 怎麼設定 daemon.json 配置檔案
阿新 • • 發佈:2019-01-26
一、引言
安裝 Docker 有很多種方式,其中使用二進位制的方式離線安裝 Docker 無亦是最簡單的一種。
然而簡單的後果帶來的是與其他安裝方式不同的配置方式。
比如說,當你作為 Docker 客戶端,想要推送本地的映象到私有映象庫的時候。此時會出現這麼一個問題:
The push refers to repository [192.168.0.201:5000/ubuntu]
INFO[2018-05-25T01:35:53.003377576-07:00] Attempting next endpoint for push after error: Get https://192.168.0.201:5000/v2/: http: server gave HTTP response to HTTPS client
Get https://192.168.0.201:5000/v2/: http: server gave HTTP response to HTTPS client
這裡就需要 Docker 客戶端自己配置一個 daemon.json 檔案,將其設定為下述內容:
{
"insecure-registries": [ "192.168.0.201:5000"] # 這是我虛擬機器中的配置
}
然而,通過二進位制安裝的 Docker,在 /etc/docker 下並沒有 daemon.json 檔案,這下該怎麼辦呢?
二、問題解決
- Start the Docker daemon:
$ sudo dockerd &
If you need to start the daemon with addtional options, modify the above command accordingly or create and edit the file/etc/docker/daemon.json
to add the custom configuration options.
也就是說,我們要麼自己指定 daemon.json 的位置,要麼就按照預設的路徑 /etc/docker
因此這個問題有兩個方式解決:
–config-file string Daemon configuration file (default “/etc/docker/daemon.json”)
也就是說,我們可以通過:
$ sudo dockerd --config-file=xxx
來指定自己的 daemon.json 的位置
2. 直接按照 daemon.json 的預設位置,沒有該檔案也直接自己新建一個即可
問題解決就是這麼簡單:)
Enjoy It ^_^