Testcontainers library (Java) is generally used along with Junit test cases to spawn a test environment within a docker container. IntelliJ IDEA provides an option to run these test cases from within the IDE.
Databases spwaned using testcontainers when run from within the IDE can become inaccessible from outside the IDE. In order to connect to such databases you can uses the database tool that comes with IDEA ultimate version.
1. Add a debug point in the code such that the testcontainer has been brought up at this point.
2. Run the test program using debug mode and wait till it stops on the break point.
3. Click on the database tool.
4. Select your database type.
5. Enter your credentials. Test your connection and save credentials.
6. Run query.