Docker-machine executable was not found on PATH while building a java quarkus app (cimg/openjdk:17.0)

Hi there!

I am trying to get a java quarkus app build, which in turn builds a docker image.
I would like to use the circleci image “cimg/openjdk:17.0” for this as it seems to check all the boxes in terms of software installed (java 17, maven 3.8.5, docker).

The build however fails when the quarkus java build tries to find/access docker in order to build the docker image itself:

[WARNING] Attempted to read Testcontainers configuration file at file:/home/circleci/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: /home/circleci/.testcontainers.properties (No such file or directory)
[INFO] docker-machine executable was not found on PATH ([/opt/sbt/bin, /opt/gradle/bin, /opt/apache-maven/bin, /home/circleci/bin, /home/circleci/.local/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin])
[ERROR] Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
[ERROR]     UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock)
[ERROR] As no valid configuration was found, execution cannot continue
[WARNING] [io.quarkus.deployment.IsDockerWorking] Could not determine version of Docker daemon

https://app.circleci.com/pipelines/github/labsai/EDDI/457/workflows/e8270184-82ef-4748-974a-fe8d4bfa4309/jobs/1344

This is my circleci script in use:

version: 2
jobs:
  build:
    docker:
      - image: cimg/openjdk:17.0
    working_directory: ~/repo
    environment:
      MAVEN_OPTS: -Xmx6400m
    steps:
      ## Checkout the source code
      - checkout

      ## Restore any files that may have been cached from previous jobs
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "pom.xml" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      ## cache the dependencies
      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}

      - run:
          name: Set permissions
          command: chmod +x mvnw

      - run:
          name: Run unit tests
          command: ./mvnw test

      - run:
          name: Build docker image
          command: ./mvnw package '-Dquarkus.container-image.build=true'

Anyone an idea how to fix this?

In order to use Docker with the Docker executor, the special step setup_remote_docker needs to be used. So it can look like this:

version: 2
jobs:
  build:
    docker:
      - image: cimg/openjdk:17.0
    working_directory: ~/repo
    environment:
      MAVEN_OPTS: -Xmx6400m
    steps:
      ## Checkout the source code
      - checkout

      ## Restore any files that may have been cached from previous jobs
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "pom.xml" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      ## cache the dependencies
      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}

      - run:
          name: Set permissions
          command: chmod +x mvnw

      - setup_remote_docker:
          version: 20.10.12

      - run:
          name: Run unit tests
          command: ./mvnw test

      - run:
          name: Build docker image
          command: ./mvnw package '-Dquarkus.container-image.build=true'

That will allow you to use the local Docker client to connect to a Docker engine. I don’t believe Docker machine is installed though. If that’s what you need, you will need to install it.

Lastly, maybe this is just an example here but with the config you shared, dependencies won’t be cached because they are not pulled/downloaded before saving.

Awesome, setup_remote_docker worked like you have suggested. Docker is installed on this image. And also thanks for the hint with the cache!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.