Open victoy opened 9 years ago
As "Caused by: java.io.IOException: Cannot run program "docker": error=2, No such file or directory", mention you are trying to execute local docker but it cannot be find.
Are you sure you have docker engine installed locally?
Do we have any updates on this problem? I am also facing this issue.
In order to help you further we need more information regarding your environment and what your are building dockerfile / build.gradle.
Sure, here is my build.gradle:
buildscript { ext { springBootVersion = '1.3.3.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath('se.transmode.gradle:gradle-docker:1.2') } }
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'spring-boot' apply plugin: 'docker'
jar { baseName = 'MicroServiceStarter' version = '0.0.1-SNAPSHOT' }
sourceCompatibility = 1.8 targetCompatibility = 1.8
repositories { mavenCentral() }
dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.slf4j:slf4j-api:1.7.14') compile('org.postgresql:postgresql') testCompile('org.springframework.boot:spring-boot-starter-test') testCompile('junit:junit:4.12') }
task buildDocker(type: Docker, dependsOn: build) { push = false applicationName = jar.baseName dockerfile = file('src/main/docker/Dockerfile') doFirst { copy { from jar into stageDir } } }
task wrapper(type: Wrapper) { gradleVersion = '2.12' }
and here is my Dockerfile:
FROM frolvlad/alpine-oraclejdk8:slim VOLUME /tmp ADD MicroServiceStarter-0.0.1-SNAPSHOT.jar app.jar RUN sh -c 'touch /app.jar' ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Hi, i was having the same issue.
Turns out, it was because i was running this inside intellij. If you run your gradle build from the same terminal you have Docker open, it solved the issue. I think it's down to environment vars, but I'm rather new to this so not sure.
Hopefully that helps!!
Thanks @Hazz223. Yes, that is most likely the issue. The terminal that are running the gradle task must be able to run traditional docker commands when not using the api
You're right @Hazz223 .. I was facing this issue when I was trying to run gradle from within my Eclipse. From the command line, I installed the wrapper using gradle wrapper command. Thereafter, when I run the ./gradlew buildDocker command, it works fine. Thanks!
Same problem after installing docker for mac beta. It works fine in terminal, but not from Idea. Native mac docker doesn't use ENVs, but it works fine in any open terminals. It would be nice if somebody find to fix it for Eclipse/Idea without wrappers or other extra steps
Looks like the same issue as #83. I'm running into the same problems with Docker for Mac 1.12.3-beta30.1. Same as @HardikDesaiBCG and @apolischuk it works fine from the terminal.
I opened from macOS terminal like this.
open -a "IntelliJ IDEA" &
Then you get all the path variables in Intellij. My build worked fine then.
You will then have to open intellij this way every time. Perhaps there's a way to get a shortcut in the dock to run this command, but I've not done that research yet
Check here for more info http://depressiverobot.com/2016/02/05/intellij-path.html
Just encountered the same issue using:
IntelliJ IDEA 2016.3.3. Docker for Mac Version 1.13.0 (15072) Gradle 3.1
Frustratingly intermittent in my case; worked fine, saved state in version control, came back and hit build and failed with the same error=2
message. Confirmed no files changed in the project, so IntelliJ seems to be able to use the path variables sometimes, not others. As others have said, all works fine from CLI.
@mattbroekhuis' workaround seems to be working for me so far.
The same for the IntelliJ IDEA 2017.1
I had this exact problem with IntelliJ IDEA 2017.2.2 on the Mac. It ended up being a Gradle Daemon that had been running before I started Docker. I killed the Gradle Daemon, then restarted IntelliJ. It worked fine after that.
Update: after some restart it broke again. I closed IntelliJ, killed the Daemon and started IntelliJ; no joy.
Starting with open -a "IntelliJ IDEA" &
worked though. Thanks @mattbroekhuis for that tip.
I faced the same problem for mac machine but for a different plugin.
While running sbt from within IntellijIDEA it gave the same error as mentioned in the issue but running it from the terminal worked fine.
It turns out that intellijIDEA uses different PATH than that is SET in environment variable.
For more details refer the blog fix PATH environment variable for IntelliJ IDEA on Mac OS X
As a solution I created a shell script
!/usr/bin/env bash
open -a "IntelliJ IDEA"
and made it execute at login refer this answer to launch an executable at login
For what it's worth, I ran into this and fixed it by upgrading Gradle for my IntelliJ project.
I had two IntelliJ projects, one I had generated recently, and another that had existed since last year. I tried adding this plugin and creating an IntelliJ gradle run/debug configuration to invoke buildDocker.
For the new project, it always worked. For the old project, it never did. In both cases, gradlew always worked from the shell.
The new project was on gradle 3.5-rc-2. the old project was on 2.1
I upgraded the old project to 3.4 and it still didn't work. Then I upgraded it to 3.5-rc-2 and it started working.
@mattbroekhuis That link you shared redirects me to Github, and yields nothing whatsoever.
Excuse me, I have the same issue on Windows 10 with VirtualBox minikube driver. I launch a command from my cmd shell on windows but get the samme error, you can find more details and configurations here: https://stackoverflow.com/questions/69070895/error-deploying-quarkus-rest-app-from-my-windows-machine-to-my-minikube-virtual. I also update to last mvn version (3.8.2) but the problem still remain..What's the problem? I have Run it inIntellij also...
You can response where you want.. Thanks very much
Roberto
All the alleged solutions are for fixing IntelliJ environment variables. How will this help when you push the build to a CI/CD pipeline not in your environment? I am seeing this problem in local as well as CodeBuild.
I'm facing the same problem in intellij idea with ubuntu in 2022, I dont know how to fix it
I got this error. How to fix this issue?