在intellij中使用sudo运行java测试 上下文
我刚刚发现了一个关于testContainers的库,它可以启动docker容器,我想在Intellij中编写一个简单的测试来测试它 问题 问题是,当我在Intellij中运行配置时,代码抛出异常,因为运行docker指令需要sudo权限在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
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命令。