Cannot create docker access object: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
mohapsub opened this issue · 39 comments
Description
I am beginner to fabric8, trying to build an image for spring-boot app.
Getting error : cannot create docker access object: trying from windows 10,
Info
[INFO] --- fabric8-maven-plugin:4.3.0:build (default) @ lb-server ---
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Container image with Docker in Kubernetes mode
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[ERROR] F8: Cannot create docker access object [Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.450 s
[INFO] Finished at: 2019-10-20T01:10:05+05:30
[INFO] Final Memory: 49M/411M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.3.0:build (default) on project lb-server: Cannot create docker access object: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
- f-m-p version : 4.3.0
- Maven version (
mvn -v
) :3
- Kubernetes / OpenShift setup and version :
- If it's a bug, how to reproduce :
<!--<!–</createOptions>–>-->
<!--</machine>-->
</configuration>
<executions>
<execution>
<goals>
<!--<goal>resource</goal>-->
<goal>help</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<docker.host.address>tcp://localhost:2375</docker.host.address>
mvn clean install
- If it's a feature request, what is your use case :
- Sample project : [GitHub Clone URL]
Are sure your docker deamon is accessible?
Are you able to use it with basic docker commands? Ideally plugins detects it on its own for most cases
i was in an assumption that there is embedded docker and that comes to live during the build.
No, it needs docker deamon. If you're using minikube for building this. You can maybe expose your docker deamon. Not sure that works on windows or not, but I usually do (eval $(minikube docker-env)
There is one more way of building without docker deamon and pushing directly to your registry. But you need to add your registry credentials of docker hub in it.
mvn fabric8:build -Dfabric8.build.jib=true
It would build it offline and push it to your dockerhub
let me explain what i am trying to build: i need a plugin that can use embedded docker to create an image. My goal is to run this from any machine. I dont want to ask people to keep installing docker to deploy code to remote cloud. Problem is jib is only useful for java image, can I use this for all types of docker image
Even above command fails with below error.
[INFO] --- fabric8-maven-plugin:4.3.0:build (default-cli) @ lb-server ---
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Container image with JIB(Java Image Builder) in Kubernetes mode
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[WARNING] F8: Cannot access cluster for detecting mode: connect timed out
[INFO] F8: Image tagging successfull!
[ERROR] F8: Failed to execute the build: java.lang.UnsupportedOperationException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.857 s
[INFO] Finished at: 2019-10-20T01:28:33+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.3.0:build (default-cli) on project lb-server: Failed to execute the build: java.lang.UnsupportedOperationException -> [Help 1]
Fabric8 Maven Plugin is also specific to Java specific container tooling. Any container image is supposed to run on any machine, and it's docker(or any other container orchestration tool) that does it. You need docker/kubernetes on some machine to be able to run your image.
You need to add some configuration also, let me give you an example:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>4.3.1</version>
<configuration>
<images>
<image>
<!-- Add your dockerhub user name here -->
<name>${YOUR_DOCKER_HUB_USERNAME}/helloworld-java:${project.version}</name>
<alias>hello-world</alias>
<build>
<from>openjdk:latest</from>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<cmd>java -jar maven/${project.name}-${project.version}.jar</cmd>
</build>
<run>
<wait>
<log>Hello World!</log>
</wait>
</run>
</image>
</images>
<authConfig>
<username>${YOUR_DOCKER_HUB_USERNAME}</username>
<password>${YOUR_DOCKER_HUB_PASSWORD}</password>
</authConfig>
</configuration>
</plugin>
i have a open(without auth) minikube running on local. how should i deploy to that?
oh, then you should be able to do it with plain mvn fabric8:build
just make sure your have docker exposed in that session.
I have no docker installed, I believe fabric8 plugin will offer an embedded docker. My intention is create a docker image using a maven plugin, and then deploy it to any k8s of my choice. so that this can work as utility to deploy any java app from anywhere. We can build anything anywhere and deploy to anywhere.
Docker deamon is inside the minikube vm
Ideally people build image using docker deamon, push it to some container image registry, and then pull it from any docker/kubernetes instance they are using
This jib option offers to build without using docker deamon and pushing directory to hub.docker.com
yes, i just want to skip push part and want to use inflight image. because this utility i will be using for POCs.
This jib option offers to build without using docker deamon and pushing directory to hub.docker.com
yes, that means i need a auth for hub.docker.com. Want to skip push part.
oh, I see. If you're using minikube, you should be able to build docker image(since docker deamon is inside minikube). and then you can do whatever your use case supports. For porting it to other machines you can simply make a tarball of your image and transfer it by other methods.
@mohapsub : bdw, if you haven't configured auth jib mode is going to fail while pushing, but it also builds tarball of your image. You can then load that tarball into whatever machine you need.
if i really dont need to push an image, is there a way i simply can create image and deploy to k8s cluster of my choice, without downloading docker? s2i?
i can store image in host(where the code is running) machine temporarily and deploy to any k8s cluster?
Sorry, I might not have understood your use case. I thought you were using minikube for deploying your kubenetes application. Am I right?
basically i want
step1# create a image without downloading docker and dont push
step2# deploy to any k8s host based on input.
two discrete steps.
if i really dont need to push an image, is there a way i simply can create image and deploy to k8s cluster of my choice, without downloading docker? s2i?
Yes, that's possible if you have minikube. The image would be stored in docker deamon which is in minikube.
i can store image in host(where the code is running) machine temporarily and deploy to any k8s cluster?
Yes, image would be stored in docker deamon. But how would you be able to deploy it to any k8s cluster? It would only be accessible in your current minikube cluster(unless you transfer it's tarball somehow or maybe push to some public/private container image registry)
basically i want
step1# create a image without downloading docker and dont push
yes, we support this
step2# deploy to any k8s host based on input.
Sorry, but I couldn't understand this use case.
two discrete steps.
"Sorry, but I couldn't understand this use case."
deploy temporary image created in step#1 to any k8s cluster of my choice
okay, you can deploy that also. So we have this workflow currently
mvn fabric8:build -> Build Image
mvn fabric8:resource fabric8:deploy -> Deploy to your cluster
"mvn fabric8:build -> Build Image"
this step is failing( in windows 10), i was thinking fabric8 has a embedded docker, but it expects me run mine.
[ERROR] F8: Cannot create docker access object [Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect]
Please perform this step and see if it helps. And remove <dockerHost>
from your plugin configuration.
it may work, but does fabric8 have a embedded docker daemon, so that i dont have to point external apps? Are you aware any other plugins that has embedded docker daemon?
No, fabric8 doesn't have this. daemon's are system level processes that are running continously in background, I don't think having them inside plugins make any sense
we used to think along similar lines, till spring-boot offered a embedded server :) it empowers developer, i can build and ship an image anywhere.
wait, what? which spring-boot are you talking about? https://spring.io/? I haven't heard of that including embedded server.
i considered tomcat as a server, couldhave been more precise
I am now pointing to a remote docker running in k8s.
I am getting below error while building image, any idea?
[INFO] --- fabric8-maven-plugin:4.3.1:resource (default) @ springbootdemo ---
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Container image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[INFO] F8: fmp-controller: Adding a default Deployment
[INFO] F8: fmp-service: Adding a default service 'springbootdemo' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating C:\Users\tsubh\Downloads\springbootdemo\target\classes\META-INF\fabric8\kubernetes\springbootdemo-deployment.yml resource
[INFO] F8: validating C:\Users\tsubh\Downloads\springbootdemo\target\classes\META-INF\fabric8\kubernetes\springbootdemo-service.yml resource
[INFO] F8: fmp-controller: Adding a default DeploymentConfig
[INFO] F8: fmp-service: Adding a default service 'springbootdemo' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating C:\Users\tsubh\Downloads\springbootdemo\target\classes\META-INF\fabric8\openshift\springbootdemo-deploymentconfig.yml resource
[INFO] F8: validating C:\Users\tsubh\Downloads\springbootdemo\target\classes\META-INF\fabric8\openshift\springbootdemo-route.yml resource
[INFO] F8: validating C:\Users\tsubh\Downloads\springbootdemo\target\classes\META-INF\fabric8\openshift\springbootdemo-service.yml resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springbootdemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\tsubh\Downloads\springbootdemo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springbootdemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\tsubh\Downloads\springbootdemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springbootdemo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\tsubh\Downloads\springbootdemo\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springbootdemo ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ springbootdemo ---
[INFO] Building jar: C:\Users\tsubh\Downloads\springbootdemo\target\springbootdemo-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) @ springbootdemo ---
[INFO]
[INFO] --- fabric8-maven-plugin:4.3.1:build (default) @ springbootdemo ---
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Container image with Docker in Kubernetes mode
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Container image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[ERROR] F8: Failed to execute the build: io.fabric8.maven.core.service.Fabric8ServiceException: Error while trying to build the image
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.544 s
[INFO] Finished at: 2019-10-30T00:40:50+05:30
[INFO] Final Memory: 55M/383M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.3.1:build (default) on project springbootdemo: Failed to execute the build: io.fabric8.maven.core.service.Fabric8ServiceException: Error while trying to build the image -> [Help 1]
@mohapsub: Could you please share logs with -X
option?
I am worried now if I have setup docker on k8s properly.
can you help me k8s deployment descriptor for docker, basically it should expose remote docker rest api? i was tryin to access remote docker using REST API.
Hi @mohapsub
I'm currently using remote docker environment(s) from my Windows 10 Home machine (where docker is not supported natively)
In order to be able to use the Docker client with (for example) Minikube's Docker daemon, you need to setup a couple of environment variables (just like @rohanKanojia mentioned).
Run the following command to check the values applicable for the Docker environment variables:
minikube docker-env
Now open your user system environment variable configuration and add those values:
From now on, whenever you create a new process, you'll be able to run any docker command successfully (docker ps
, docker images
, etc.)
FMP will detect these values too.
thanks my problem resolved long back, i was not very active. Thanks for posting this