Hi I'm trying to use the trick described here to allow continuous building inside docker containers. The trick works fine when I open two separate terminals on my host machine, but fails when used in docker containers.
docker-compose.yml
build_server:
image: gradle:6.3.0-jdk8
working_dir: /home/gradle/server
volumes:
- ./server:/home/gradle/server
command: ["gradle", "build", "--continuous", "-x", "test"]
server:
image: gradle:6.3.0-jdk8
working_dir: /home/gradle/server
volumes:
- ./server:/home/gradle/server
ports:
- 8080:8080
depends_on:
- build_server
restart: on-failure
command: ["gradle", "bootRun"]
The error message I got from server container:
server_1 | FAILURE: Build failed with an exception.
server_1 |
server_1 | * What went wrong:
server_1 | Gradle could not start your build.
server_1 | > Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
server_1 | > Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService().
server_1 | > Timeout waiting to lock checksums cache (/home/gradle/server/.gradle/checksums). It is currently in use by another Gradle instance.
server_1 | Owner PID: unknown
server_1 | Our PID: 31
server_1 | Owner Operation: unknown
server_1 | Our operation:
server_1 | Lock file: /home/gradle/server/.gradle/checksums/checksums.lock
It looks like gradle has added locks on local cache files and prevents bootRun
task from being run in the other container. However, the trick works fine when I run the tasks in two terminals on my host machine, or when I only run the build_server
container and run bootRun
on host terminal. I wonder why it doesn't work inside docker containers. Thanks for helping in advance!