I use gradle bootBuildImage to build the docker image for my springboot application with the following settings in build.gradle.kts:
tasks.named<BootBuildImage>("bootBuildImage") {
imageName = "repository.intra.net:28082/service:${project.version}"
docker {
host = "tcp://dev1.docker.intra.net:2376"
isTlsVerify = true
certPath = "~/docker-certs/"
}
}
but gradle does not use the remote docker host but gives the following error:
> Running creator
[creator] ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: connection refused
I am using these versions:
Gradle version: 7.4.2
SpringBoot version: 2.7.0
Does anyone know how to solve this?
Related
I discover docker. I installed gitlab-runner with a docker image and it works.
i linked gitlab.com to my runner and it works.
However, in the .gitlab-ci.yml when I docker builds I have an error:
dial tcp: lookup docker on x.x.x.9:53: no such host
$ docker info
Client:
Context: default
Debug Mode: false
Server:
ERROR: error during connect: Get http://docker:2375/v1.24/info: dial tcp: lookup docker on x.x.x.9:53: no such host
errors pretty printing info
I can't build my spring-boot image thank
When I'm trying to get the Docker integration of IntelliJ (Ultimate 2018.3.3) working together with local running Docker Desktop (Version 2.0.0.3 (31259)), I'm getting the following error:
Cannot connect: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost:127.0.0.1:2375
caused by: java.net.ConnectException: Connection refused: no further information
I found the following question: IntelliJ cannot connect to protected tcp Docker socket
But this solution leads to this error:
Cannot connect: com.github.dockerjava.api.exception.DockerClientException: Enabled TLS verification (DOCKER_TLS_VERIFY=1) but certificate path (DOCKER_CERT_PATH) is not defined.
I searched for the cert path of Docker Desktop but found nothing yet because the new Hyper-V solution of Docker Desktop doesn't run docker-machine native any more.
The solution is to enable exposing the Docker deamon on tcp:localhost:2375 without TLS.
This option can be found in general settings of Docker Desktop (Version 2.0.0.3).
Setting / General / Expose daemon on tcp://localhost:2375 without TLS
I'm trying to build sample microservice app using this tutorial Tutorial. jhipster v5.2.1 So I've created a gateway and an armory started consul using this command:
docker-compose -f src/main/docker/consul.yml up
While I've pointed into the armory folder writing this command :
./gradlew
I got this error :
2018-09-03 13:20:11.235 WARN 7224 --- [ restartedMain] o.s.c.c.c.ConsulPropertySourceLocator : Unable to load consul config from config/armory-swagger/
com.ecwid.consul.transport.TransportException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8600 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Could you please help me
If you are using the toolbox you have to replace localhost by the IP of your Docker machine vm. You will have to ajust the bootstrap.yml properties to point to this adress.
You should also be able to apply this trick : https://www.jhipster.tech/tips/020_tip_using_docker_containers_as_localhost_on_mac_and_windows.html
I just changed fail-fast to false in bootstrap-prod.yml
You can disable Spring Cloud Config this way.
fail-fast: false
Otherwise you have to provide proper configuration as stated above.
Or you can run this command if you have already installed consul on your development machine.
consul agent -dev
I am trying to setup Jenkins build for my simple java microservice with Kubernetes cluster.
mvn clean package fabric8:build
I've defined DOCKER_HOST environment variable within Jenkins
DOCKER_HOST=tcp://192.168.20.1:2375
My build fails with the following error after successfully building the fat JAR
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:3.5.31:build (default-cli) on project echo: Cannot create docker access object: Cannot extract API version from server http://192.168.20.1:2375 : No route to host -> [Help 1]
My Docker host runs on linux. I changed the daemon.json to add the following and restarted docker host
{
"ipv6": false ,
"live-restore": true,
"hosts" : ["tcp://192.168.20.1:2375"]
}
Still the issue persists:
Couple of questions:
Why is fabric8 resolving tcp to http? Pls looks at the error message.
What else needs to be done on Docker host to serve requests on tcp://192.168.20.1:2375?
TIA
This is purely a Docker host setup issue.
To access Docker daemon remotely, tcp socket should be enabled. More details here: https://docs.docker.com/engine/reference/commandline/dockerd/#examples
Based on our setup, I had edited the /etc/docker/daemon.json to add the "hosts" parameter
{
"ipv6": false ,
"live-restore": true,
"hosts" : ["tcp://192.168.20.1:2375"]
}
Restart docker daemon using the command
systemctl restart docker.service
Make sure docker daemon is listening to port 2375
netstat -tunlp | grep 2375
tcp 0 0 192.168.20.1:2375 0.0.0.0:* LISTEN 14648/dockerd
If after doing the above if you are still not able to access Docker daemon remotely, check if there are any firewalls that are blocking the external requests.
You can either stop them or set up a rule to allow the traffic based on your configuration.
Hope this helps
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.
The Spring Boot client app, running inside the container, is trying to reach localhost:8761, and since in the context of this Docker container 'localhost' refers to the container's address. There's nothing running on port 8761 of the container and hence you are seeing the connection refused error.
This might help:
Specify the location of Eureka in your client app's configuration via its application.yml:
eureka:
client:
serviceUrl:
defaultZone: <IP-address-of-Eureka-server>/eureka/
The <IP-address-of-Eureka-server> can be either an IP address or a host name that can be resolved from inside the container. If you want to pass the address of your host VM (the host that runs your Docker container), you can pass it as an environment variable using --env eureka.client.serviceUrl.defaultZone=xx.xx.xx.xx form. Something like this:
$ docker run ... --env eureka.client.serviceUrl.defaultZone=xx.xx.xx.xx
On a related note, if your Spring Boot client application also needs to register itself with Eureka, then you will need additional configuration to publish the resolvable host name and port of your Spring Boot app to Eureka. You can add the following to your application.yml:
eureka:
instance:
hostname: <client-host>
nonSecurePort: <client-port>
Where,
<client-host> is the resolvable host name of the client app container; and
<client-port> is the host VM's port that's bound to the exposed port of the container>
Again, you can pass these using the --env argument as shown above.
$ docker run -p 9001:8080 ... \
--env eureka.instance.hostname=yy.yy.yy.yy \
--env eureka.instance.nonSecurePort=9001
Be sure to set yy.yy.yy.yy to your VM's IP address.
If you want to test in your local machine then try with host ip address. To do that use the below configuration.
eureka.client.service-url.defaultZone=http://host.docker.internal:8761/eureka/