Sonar Container exists with postgres when running in docker with jenkins


(Shashank S) #1

I am using sonar and postgres with Jenkins as soon as i docker compose up , sonar container exists and i am not able to localhost:9000
latest sonar version

this is the log

2019.02.18 19:28:38 ERROR web[][o.postgresql.Driver] Connection error: 

org.postgresql.util.PSQLException: The connection attempt failed.

at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)

at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)

at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)

at org.postgresql.Driver.makeConnection(Driver.java:450)

at org.postgresql.Driver.connect(Driver.java:252)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

at org.sonar.db.profiling.NullConnectionInterceptor.getConnection(NullConnectionInterceptor.java:31)

at org.sonar.db.profiling.ProfiledDataSource.getConnection(ProfiledDataSource.java:323)

at org.sonar.db.DefaultDatabase.checkConnection(DefaultDatabase.java:106)

at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:75)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)

at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)

at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)

at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)

at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)

at org.picocontainer.behaviors.Stored.start(Stored.java:110)

at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)

at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)

at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)

at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)

at org.sonar.server.platform.Platform.start(Platform.java:211)

at org.sonar.server.platform.Platform.startLevel1Container(Platform.java:170)

at org.sonar.server.platform.Platform.init(Platform.java:86)

at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.net.UnknownHostException: db

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at org.postgresql.core.PGStream.<init>(PGStream.java:68)

at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144)

... 42 common frames omitted

2019.02.18 19:28:38 ERROR web[][o.s.s.p.Platform] Web server startup failed

java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').

at org.sonar.db.DefaultDatabase.checkConnection(DefaultDatabase.java:108)

at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:75)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)

at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)

at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)

at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)

at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)

at org.picocontainer.behaviors.Stored.start(Stored.java:110)

at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)

at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)

at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)

at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)

at org.sonar.server.platform.Platform.start(Platform.java:211)

at org.sonar.server.platform.Platform.startLevel1Container(Platform.java:170)

at org.sonar.server.platform.Platform.init(Platform.java:86)

at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The connection attempt failed.)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

at org.sonar.db.profiling.NullConnectionInterceptor.getConnection(NullConnectionInterceptor.java:31)

at org.sonar.db.profiling.ProfiledDataSource.getConnection(ProfiledDataSource.java:323)

at org.sonar.db.DefaultDatabase.checkConnection(DefaultDatabase.java:106)

... 29 common frames omitted

Caused by: org.postgresql.util.PSQLException: The connection attempt failed.

at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)

at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)

at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)

at org.postgresql.Driver.makeConnection(Driver.java:450)

at org.postgresql.Driver.connect(Driver.java:252)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

... 34 common frames omitted

Caused by: java.net.UnknownHostException: db

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at org.postgresql.core.PGStream.<init>(PGStream.java:68)

at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144)

... 42 common frames omitted

2019.02.18 19:28:38 INFO app[][o.s.a.SchedulerImpl] Process [web] is stopped

2019.02.18 19:28:38 INFO app[][o.s.a.SchedulerImpl] Process [es] is stopped

2019.02.18 19:28:38 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143

2019.02.18 19:28:38 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped

(Adam Gabryś) #2

Here is a problem:

Please paste your docker-compose configuration.


(Shashank S) #3

version: ‘3’

services:
jenkins:
image: jenkins
build: jenkins/
ports:
- 8080:8080
volumes:
- ./data/jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
networks:
- sonarnet

sonarqube:
image: sonar
build: sonar/
ports:
- “9000:9000”
networks:
- sonarnet
environment:
- sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
volumes:
- sonarqube_conf:/opt/sonarqube/conf
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins

db:
image: postgres
networks:
- sonarnet
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data

networks:
sonarnet:
driver: bridge

volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data: