Reputation: 3
I'm trying to setup a CD/CI build environment with docker compose. I have a jenkins container, a sonar container and an archiva container. The problem is, my jenkins cannot connect to sonar and 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.
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. Does anyone how can i join all the environments together? Been struggling with this problem for almost a week now
Upvotes: 0
Views: 627
Reputation: 710
To reference your sonarqube container from Jenkins use sonarqube:9000 docker will translate your service name sonarqube to the ip of that container.
I would also recommend using different networks rather than links to connect your containers.
Upvotes: 2