You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu系统Docker添加daemon.json文件及解决文件不存在报错

How to Create and Configure daemon.json for Docker on Ubuntu

Hey there! That error makes total sense—you're trying to reference a file that doesn't exist yet. Let's walk through creating and setting up /etc/docker/daemon.json properly:

Step 1: Create the daemon.json file

First, we'll create the file in the correct directory. You can jump straight into editing it with a simple text editor like nano (this will create the file if it doesn't exist):

sudo nano /etc/docker/daemon.json

Step 2: Add your Docker daemon configuration

Next, add your desired settings to the blank file. This is where you can configure things like registry mirrors (for faster image pulls), storage drivers, or other daemon behaviors. Here's a common example to get you started:

{
  "registry-mirrors": ["https://your-preferred-mirror.example.com"],
  "storage-driver": "overlay2"
}

Adjust or add other settings based on your needs—just make sure the JSON syntax is valid (no trailing commas, properly nested brackets).

Step 3: Save and exit the editor

In nano, press Ctrl+O to save the file, hit Enter to confirm the filename, then Ctrl+X to exit the editor.

Step 4: Apply the configuration

Now we need to reload the Docker daemon and restart the service to pick up the new settings:

sudo systemctl daemon-reload
sudo systemctl restart docker

Step 5: Verify the configuration works

To confirm Docker is using your new daemon.json settings, run:

docker info

Look for sections like Registry Mirrors or Storage Driver in the output—they should match what you set in the file.

Quick note about the dockerd --config-file command

You don't usually need to run dockerd with the --config-file flag manually. Docker automatically checks /etc/docker/daemon.json by default when starting up. If you do want to use that flag for testing, just ensure the file exists first (which we've now created!) and run it with sudo:

sudo dockerd --config-file /etc/docker/daemon.json

内容的提问来源于stack exchange,提问作者Ravi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 18:27:34