Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Could not find a working container runtime strategy" when starting MySqlContainer #813

Closed
msahakyan-korio opened this issue Aug 4, 2024 · 4 comments
Labels
triage Investigation required

Comments

@msahakyan-korio
Copy link

msahakyan-korio commented Aug 4, 2024

Expected Behaviour
Should work without any issue (as it works in local env)
Actual Behaviour
I get Could not find a working container runtime strategy
Testcontainer Logs
2024-08-04T23:22:17.338Z testcontainers [DEBUG] Checking container runtime strategy "TestcontainersHostStrategy"...
2024-08-04T23:22:17.339Z testcontainers [DEBUG] Container runtime strategy "TestcontainersHostStrategy" is not applicable
2024-08-04T23:22:17.340Z testcontainers [DEBUG] Checking container runtime strategy "ConfigurationStrategy"...
2024-08-04T23:22:17.340Z testcontainers [DEBUG] Container runtime strategy "ConfigurationStrategy" is not applicable
2024-08-04T23:22:17.340Z testcontainers [DEBUG] Checking container runtime strategy "UnixSocketStrategy"...
2024-08-04T23:22:17.340Z testcontainers [DEBUG] Container runtime strategy "UnixSocketStrategy" is not applicable
2024-08-04T23:22:17.340Z testcontainers [DEBUG] Checking container runtime strategy "RootlessUnixSocketStrategy"...
2024-08-04T23:22:17.341Z testcontainers [DEBUG] Container runtime strategy "RootlessUnixSocketStrategy" is not applicable
2024-08-04T23:22:17.341Z testcontainers [DEBUG] Checking container runtime strategy "NpipeSocketStrategy"...
2024-08-04T23:22:17.341Z testcontainers [DEBUG] Container runtime strategy "NpipeSocketStrategy" is not applicable
Tearing down test environment.
FAIL test/app.spec.ts
● Test suite failed to run
Could not find a working container runtime strategy
8 |
9 | async setup() {
> 10 | const mySqlContainer = await new MySqlContainer()
| ^
11 | .start()
12 |
13 | this.containers.push(mySqlContainer);
at getContainerRuntimeClient (../node_modules/testcontainers/src/container-runtime/clients/client.ts:64:9)
at MySqlContainer.start (../node_modules/testcontainers/src/generic-container/generic-container.ts:81:20)
at MySqlContainer.start (../node_modules/@testcontainers/mysql/src/mysql-container.ts:44:7)
at TestContainersEnvironment.setup (../src/config/test/test.containers.environment.ts:10:32)
at TestEnvironment.setup (../src/config/test/test.environment.ts:18:17)

Steps to Reproduce

  1. The issue is not actual for local environment but actual for gitlab ci/cd pipeline
  2. gitlab-ci.yaml
stages:
  - test

test:
  stage: test
  image: node:20-alpine
  services:
    - docker:dind
  variables:
    DEBUG: testcontainers*
    DOCKER_TLS_CERTDIR: ""
  script:
    - npm install
    - npm test
  tags:
    - readonic-test-runner
  1. in github pipeline I see the following error
  2. Could not find a working container runtime strategy

Environment Information

  • Operating System:
  • Docker Version: docker:23.0.1
  • Node version: node:20-alpine
  • Testcontainers version: 10.11.0

Additional info:
My runner config:

[[runners]]
name = "My Docker Runner"
url = "https://gitlab.some-host.ca/"
id = 14
token = "XXXXXXXXXXXXXXXX"
token_obtained_at = 2024-08-04T21:09:18Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "docker:23.0.1"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/certs/client", "/cache"]
shm_size = 0
network_mtu = 0

@msahakyan-korio
Copy link
Author

I checked #785 this issue and tried to follow all the instructions but without success :(

@cristianrgreco
Copy link
Collaborator

@msahakyan-korio testcontainers isn't able to find a single valid container runtime. Although you say Docker is installed, it hasn't exposed a socket in any of the known locations (root or rootless locations). I would double check that it's running.

@cristianrgreco cristianrgreco added the triage Investigation required label Aug 5, 2024
@msahakyan-korio
Copy link
Author

msahakyan-korio commented Aug 6, 2024

@cristianrgreco
After these updates
volumes = ["/certs/client", "/cache", "/var/run/docker.sock:/var/run/docker.sock"] and running with this env TESTCONTAINERS_RYUK_DISABLED: "true" the issue resolved but brought other ones.

Error message:
2024-08-06T00:47:48.063Z testcontainers [ERROR] [46ff8425d660] Container failed to be ready: Error: Port 80 not bound after 60000ms

I even tried for the simplest setup but still the same issue.

import {GenericContainer, StartedTestContainer} from 'testcontainers';
export class TestContainersEnvironment {
private containers: StartedTestContainer[] = [];

async setup() {
const container = await new GenericContainer('alpine')
.withExposedPorts(80)
.withCommand(['sh', '-c', 'while :; do echo "Hello World"; sleep 1; done'])
.start();

console.log(`Container started with IP: ${container.getHost()}`);
console.log(`Container port: ${container.getMappedPort(80)}`);

....
}
}

@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Aug 6, 2024

@msahakyan-korio

After these updates
volumes = ["/certs/client", "/cache", "/var/run/docker.sock:/var/run/docker.sock"] and running with this env TESTCONTAINERS_RYUK_DISABLED: "true" the issue resolved

Setting those fields and env variables wouldn't have resulted in testcontainers suddenly finding an available container runtime.

2024-08-06T00:47:48.063Z testcontainers [ERROR] [46ff8425d660] Container failed to be ready: Error: Port 80 not bound after 60000ms

I'd suggest you look at the logs to see why port 80 isn't being bound, or if it's being bound why it isn't available in your network, and raise an issue here once you've established that there's an issue with Testcontainers, and not with how it's being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Investigation required
Projects
None yet
Development

No branches or pull requests

2 participants