Answer the question
In order to leave comments, you need to log in
How to link Jenkins and Postgres in Docker?
Good afternoon.
Decided to play around with docker and CI. Installed docker on Ubuntu 16.04, downloaded docker-ui, postgres and jenkins images. My current container startup script is:
docker run --name myUiDocker -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock -d uifd/ui-for-docker
docker run --name myPostgres -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres
docker run --name myJankins -p 9001:8080 -p 50000:50000 --link myPostgres:postgres -v /home/docker/jenkins_home:/var /jenkins_home -d jenkins
I configured Jenkins to take a spring-boot java application from git and run it. On startup I get this kind of exception: "Unable to build Hibernate SessionFactory: Unable to open JDBC Connection for DDL execution: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Connection refused (Connection refused) -> [Help 1]".
With pgAdmin, I connect to the database normally at 127.0.0.1:5432, if I just manually launch the application from the Jenkins working directory (java -jar aaa.jar), then everything is fine too, the application sees the database. So I'm setting up Docker incorrectly.
Please tell me what am I doing wrong?
Thank you.
Answer the question
In order to leave comments, you need to log in
I have not worked with docker for a long time, but it seems that you still need to specify EXPOSE port
difference-between-expose-and-publish-in-docker
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question