With your method you are replacing the daemon.json that is also in place from the nvidia driver, if you want to inject something to the file I would rather do it like this: sed -i '0,/{/a\ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],' /etc/docker/daemon.json With this method you are injecting the "registry-mirrors" after the first found { and the pre configured  nvidia-runtime configuration in the file is untouched.   You also don't need to create the path /etc/