Docker中的Jenkins:无法解析VCS主机

时间:2017-05-28 02:33:52

标签: docker jenkins docker-compose

我正在将现有Jenkins实例从一台服务器迁移到另一台服务器托管的Docker。顺便说一句,我是Docker的新手。

我能够毫无问题地在Docker中运行Jenkins实例。但是,当我开始工作时,它无法连接到VCS仓库: -

stderr: fatal: unable to access 'http://tfs/path/to/app/': Could not resolve host: tfs
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:807)

我的Docker配置应该如何才能让VCS主机解析?

我当前的docker-compose.xml如下所示: -

version: '2'
services:
  jenkins:
    image: "jenkinsci/jenkins"
    ports:
     - "80:8080"
    volumes:
     - ./jenkins:/var/jenkins_home
    environment:
      JAVA_OPTS: "-Xms2048m -Xmx4096m"

非常感谢。

1 个答案:

答案 0 :(得分:1)

如果您有内部DNS服务器,请按以下方式添加:

dns: - 1.2.3.4 - 4.3.2.1

extra_hosts

更多信息:dplyr::mutate_if

或者您可以像这样使用extra_hosts: - "tfs:x.x.x.x"

x.x.x.x

tfs替换为{{1}}主机的IP。

更多信息:https://docs.docker.com/compose/compose-file/compose-file-v2/#dns