I build a spring-server and a spring-client with eureka on docker and I try to connect the client to the server.
When I try this in my build.gradle
:
docker {
maintainer = 'Me'
baseImage = 'java:8'
}
distDocker {
exposePort 8080
setEnvironment 'JAVA_OPTS', '-Dspring.profiles.active=docker'
}
everything works.
But I want to use the Dockerfile
I wrote, so I use buildDocker
instead of distDocker
and I use it this way:
task buildDocker(type: Docker, dependsOn: build) {
dockerfile = file('src/main/docker/Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
}
}
with this Dockerfile
:
FROM java:8
ADD myjar-1.0.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]
and that always leads to a
connection refused-error or more precisely to a ClientHandleException: Connection to http://localhost:8761 refused
I don't really understand where the problem is? If I don't try to connect to the server both ways work but if I try to connect only distDocker
works.