docker - 在 CentOS 中部署 docker 容器时 DNS 无法解析
问题描述
尝试在 Cent-OS 中部署 docker 容器时出现以下错误( DNS 未在容器内解析)
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://github.com/Asymmetrik/node-fhir-server-core.git
Directory: /srv/cpr-fhir
Output:
fatal: unable to access 'https://github.com/Asymmetrik/node-fhir-server-core.git/': Could not resolve host: github.com
**Operating System: CentOS Linux 8 (Core)
Docker version: Version: 19.03.7**
解决方案
实际上这是因为 docker 容器没有使用本机 DNS。
使固定
进入docker配置文件 /lib/systemd/system/docker.service
在 ExecStart 命令中附加 dns 变量,如下所示
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --dns 8.8.8.8
推荐阅读
- android - 我如何将多个数据保存到 Firebase 实时数据库中
- google-cloud-platform - 是否可以通过浏览器中的 JavaScript 连接到 Google IOTCore
- php - php mysqli数据计数和搜索功能不起作用
- java - 从工具栏菜单在 web 视图中共享当前 url
- python - 如何将两个熊猫系列合并到表格中
- jquery - 滑块卡在第一张幻灯片上
- java - 接受具有特定注释的对象的参数
- java - 如何在没有地图的情况下通过搜索获取地址列表?
- interface - 面向数据设计中的接口
- jenkins - 如何在外部函数中定义 Jenkinsfile 的并行阶段?