Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在intellij中使用sudo运行java测试 上下文_Java_Docker_Intellij Idea_Testcontainers - Fatal编程技术网

在intellij中使用sudo运行java测试 上下文

在intellij中使用sudo运行java测试 上下文,java,docker,intellij-idea,testcontainers,Java,Docker,Intellij Idea,Testcontainers,我刚刚发现了一个关于testContainers的库,它可以启动docker容器,我想在Intellij中编写一个简单的测试来测试它 问题 问题是,当我在Intellij中运行配置时,代码抛出异常,因为运行docker指令需要sudo权限 23:18:52.180 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - EnvironmentAndSystemPropertyClientProvide

我刚刚发现了一个关于testContainers的库,它可以启动docker容器,我想在Intellij中编写一个简单的测试来测试它

问题 问题是,当我在Intellij中运行配置时,代码抛出异常,因为运行docker指令需要sudo权限

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)
试图将当前用户添加到docker组
sudo usermod-aG docker$USER
我仍然无法在Intellij中运行应用程序,即使我用sudo启动它

工作替代方案 在我有pom的地方直接使用
sudo mvn test

问题:
我可以让它在Intellij内部工作吗?

Intellij IDEA没有这样的选项。如果将当前用户添加到docker组,则不需要使用sudo运行docker命令。Intellij IDEA没有这样的选项。如果将当前用户添加到docker组,则不需要使用sudo运行docker命令。