简体   繁体   中英

Testcontainers in Windows environment on GitHub Actions: “Could not find a valid Docker environment. Please see logs and check configuration”

We're using testcontainers-java heavily in our spring-boot-admin project. Since we also want to be able to run our Maven build also on Windows, we added a windows-latest environment to our GitHub Actions Pipeline using a Matrix strategy build ( as supposed in this answer ) like this:

name: build

on:
  push:

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.os }}
    steps:

      - uses: actions/checkout@v2

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Build with Maven
        run: |
          mvn -B install --no-transfer-progress

Now our Testcontainers JUnit testcase failes with (see full build log ):

[INFO] Running de.codecentric.boot.admin.server.eventstore.HazelcastEventStoreWithClientConfigTest
Error:  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.877 s <<< FAILURE! - in de.codecentric.boot.admin.server.eventstore.HazelcastEventStoreWithClientConfigTest
Error:  de.codecentric.boot.admin.server.eventstore.HazelcastEventStoreWithClientConfigTest  Time elapsed: 0.877 s  <<< ERROR!
java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration

So any idea what we can do to fix that?

The problem is that in Windows Server there are only Windows containers activated per default (no Linux containers). As Sergei Egorov stated :

The problem with windows-latest is that it uses Windows containers, not Linux containers. It means that Testcontainers itself works, but all the images that it starts are Linux-based and, in Windows containers mode, they obviously fail to start:)

A "fix" for that would be to have a GitHub Action environment with Linux containers enabled. But after some googeling this doesn't seem to be that easy. First I though LCOW (Linux Containers on Windows) would simply need to be enabled. But as this great elaboration states, it's not easy (or even possible) to activate LCOW on the GitHub Actions Windows env.

I digged deeper into the issue and found that LCOW was officially deprecated in 20.10 in favour of WSL2, that brings in native Linux runtime and also Docker for Desktop on Windows 10 already favours this approach .

BUT: We are on Windows Server 2019 , which is not Windows 10 Desktop. And on GitHub Actions we only have the server version in it's nano flavor. There's sadly an open issue for the WSL2 support in Windows Server 2019 . And scanning the GitHub Actions Windows Server 2019 docs I found out that there's only WSLv1 installed right now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM