[英]Docker-compose linking containers
I'm trying to setup a CD/CI build environment with docker compose. 我正在尝试使用docker compose设置CD / CI构建环境。 I have a jenkins container, a sonar container and an archiva container. 我有一个詹金斯容器,一个声纳容器和一个档案容器。 The problem is, my jenkins cannot connect to sonar and archiva. 问题是,我的詹金斯无法连接声纳和Archiva。
I tried linking multiple containers together or joining them in the same network, but still no success. 我尝试将多个容器链接在一起或将它们加入同一网络,但仍然没有成功。
In jenkins, I get the following error: 在詹金斯,我得到以下错误:
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8081 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
This is my docker-compose file. 这是我的docker-compose文件。
version: '2'
volumes:
data-jenkins:
driver: 'local'
data-postgres:
driver: 'local'
data-sonarqube-conf:
driver: 'local'
data-sonarqube-data:
driver: 'local'
data-archiva:
driver: 'local'
services:
jenkins:
image: 'jenkins'
ports:
- '8080:8080'
restart: 'always'
volumes:
- 'data-jenkins:/var/jenkins_home'
links:
- 'sonarqube:sonarqube'
postgres:
image: 'postgres:9.6.1'
environment:
- 'POSTGRES_USER=postgres'
- 'POSTGRES_PASSWORD=postgres'
ports:
- '5432:5432'
restart: 'always'
volumes:
- 'data-postgres:/var/lib/postgresql/data'
sonarqube:
image: 'sonarqube'
depends_on:
- 'postgres'
ports:
- '9000:9000'
links:
- 'postgres:postgres'
environment:
- 'SONARQUBE_JDBC_URL=jdbc:postgresql://postgres:5432/'
- 'SONARQUBE_JDBC_USERNAME=postgres'
- 'SONARQUBE_JDBC_PASSWORD=postgres'
volumes:
- 'data-sonarqube-data:/var/lib/sonarqube/data'
- 'data-sonarqube-conf:/var/lib/sonarqube/conf'
archiva:
image: 'xetusoss/archiva'
ports:
- '8081:8080'
volumes:
- 'data-archiva:/var/archiva'
environment:
- 'SSL_ENABLED=false'
It seems the Jenkins container is living in a seperate environment. 詹金斯(Jenkins)容器似乎生活在一个单独的环境中。 Does anyone how can i join all the environments together? 有谁能将所有环境融合在一起? Been struggling with this problem for almost a week now 现在已经为这个问题苦苦挣扎了近一个星期
To reference your sonarqube container from Jenkins use sonarqube:9000 docker will translate your service name sonarqube to the ip of that container. 要从Jenkins引用您的sonarqube容器,请使用sonarqube:9000 docker将您的服务名称sonarqube转换为该容器的ip。
I would also recommend using different networks rather than links to connect your containers. 我还建议您使用其他网络,而不是使用链接来连接您的容器。
这是因为ping即将进入声纳尔。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.