5

Context

I've just found about testContainers, a library which can start docker containers and I wanted to test it writing a simple test inside Intellij.

Problem

The problem is that when i run the configuration in Intellij, the code throws Exception because running docker instructions need sudo permissions.

23:18:52.180 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - EnvironmentAndSystemPropertyClientProviderStrategy: failed with exception InvalidConfigurationException (ping failed)
23:18:52.186 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (ping failed). Root cause NoSuchFileException (/var/run/docker.sock)
23:18:52.187 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
23:18:52.187 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy -     EnvironmentAndSystemPropertyClientProviderStrategy: failed with exception InvalidConfigurationException (ping failed)
23:18:52.187 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy -     EnvironmentAndSystemPropertyClientProviderStrategy: failed with exception InvalidConfigurationException (ping failed)
23:18:52.187 [main] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy -     UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (ping failed). Root cause NoSuchFileException (/var/run/docker.sock)

Tried to add current user to docker group sudo usermod -aG docker $USER Still i can't run the app inside in Intellij, even if i start it with sudo.

Working alternative

Use sudo mvn test directly where i have the pom.

Question:

Can I make it work inside Intellij?

thmmy95
  • 361
  • 2
  • 18

0 Answers0