I have a gradle task which runs a bash script which in turn cleans up some docker containers, it's part of a pipeline of tasks.
If I run this task from the command line, it works fine; if I run it from within IntelliJ IDEA, it fails because I cannot find the docker
command.
This is the task:
task localDockerClean(type: Exec) {
executable './cleanDocker.sh'
ignoreExitValue true
}
This is the script:
#! /bin/bash
echo "Init - Clean Docker Containers"
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker system prune --force --volumes
echo "End - Clean Docker Containers"
And this is the output that only happens when run from IntelliJ IDEA:
> Task :scripts:migrations:localDockerClean
Init - Clean Docker Containers
./cleanDocker.sh: line 4: docker: command not found
./cleanDocker.sh: line 4: docker: command not found
./cleanDocker.sh: line 5: docker: command not found
./cleanDocker.sh: line 5: docker: command not found
./cleanDocker.sh: line 6: docker: command not found
End - Clean Docker Containers
Looks like the script has no access to the docker command which is in the PATH in my MacOS but only when run from the IDE, otherwise it works fine.
Any idea how to fix this issue in my IDE?
Thank you!