Streamlining Local Development with Dev Containers and Testcontainers Cloud

December 8, 2025 · 1149 words · 6 min

In today’s world of fast-paced development, setting up a consistent and efficient development enviro

In today’s world of fast-paced development, setting up a consistent and efficient development environment for all team members is crucial for overall productivity. Although Docker itself is a powerful tool that enhances developer efficiency, configuring a local development environment still can be complex and time-consuming. This is where (or dev containers) come into play. Dev containers provide an all-encompassing solution, offering everything needed to start working on a feature and running the application seamlessly. In specific terms, dev containers are Docker containers (running locally or remotely) that encapsulate everything necessary for the software development of a given project, including integrated development environments (IDEs), specific software, tools, libraries, and preconfigured services.  This description of an isolated environment can be easily transferred and launched on any computer or cloud infrastructure, allowing developers and teams to abstract away the specifics of their operating systems. The dev container settings are defined in a file, which is located within a given project, ensuring consistency across different environments. However, development is only one part of a developer’s workflow. Another critical aspect is testing to ensure that code changes work as expected and do not introduce new issues. If you use Testcontainers for integration testing or rely on Testcontainers-based services to run your application locally, you must have Docker available from within your dev container.  In this post, we will show how you can run Testcontainers-based tests or services from within the dev container and how to leverage within a dev container securely and efficiently to make interacting with Docker even easier.  To get started with dev containers on your computer using this tutorial, you will need: There’s no need to preconfigure your project to support development containers; the IDE will do it for you. But, we will need some Testcontainers usage examples to run in the dev container, so let’s use the existing repository. It contains the implementation of a Spring Boot-based microservice application for managing a catalog of products. The branch contains the implementation of Testcontainers-based integration tests and services for local development.  Although this project typically requires Java 21 and Maven installed locally, we will instead use dev containers to preconfigure all necessary tools and dependencies within the development container.  To begin, clone the project: Next, open the project in your local IntelliJ IDE and install the Dev Containers plugin (Figure 1). Next, we will add a   file with the requirements to the project. In the context menu of the project root, select (Figure 2). We’ll need Java 21, so let’s use the Java Dev Container Template. Then, select version 21 and enable (Figure 3). Select and you’ll see a newly generated file. Let’s now tweak that a bit more.  Because Testcontainers requires access to Docker, we need to provide some access to Docker inside of the dev container. Let’s use an existing to do this. Features enhance development capabilities within your dev container by providing self-contained units of specific container configuration including installation steps, environment variables, and other settings.  You can add the Docker-in-Docker feature to your to install Docker into the dev container itself and thus have a Docker environment available for the Testcontainers tests. Your file should now look like the following: Now you can run the container. Navigate to and click on the Dev Containers plugin and select . The window will open (Figure 4). In the window, you can select the Git branch and specify where to create your dev container. By default, it uses the local Docker instance, but you can select the ellipses ( ) to add additional Docker servers from the cloud or WSL and configure the connection via SSH. If the build process is successful, you will be able to select the desired IDE backend, which will be installed and launched within the container (Figure 5). After you select , a new IDE window will open, allowing you to code as usual. To view the details of the running dev container, execute in the terminal of your host (Figure 6). If you run the TestApplication class, your application will start with all required dependencies managed by Testcontainers. (For more implementation details, refer to the “ on GitHub.) You can see the services running in containers by executing in your IDE terminal (within the container). See Figure 7. To reduce the load on local resources and enhance the observability of Testcontainers-based containers, let’s switch from the Docker-in-Docker feature to the Testcontainers Cloud (TCC) feature:  . This feature will install and run the Testcontainers Cloud agent within the dev container, providing a remote Docker environment for your Testcontainers tests. To enable this functionality, you’ll need to obtain a valid , which the Testcontainers Cloud agent will use to establish the connection. If you don’t already have a Testcontainers Cloud account, you can Once logged in, you can to generate the necessary token (Figure 8). To use the token value, we’ll utilize an file. Create an environment file under and add your newly generated token value (Figure 9). Be sure to add to to prevent it from being pushed to the remote repository. In your file, include the following options: Let’s rebuild and start the dev container again. Navigate to , select the Dev Containers plugin, then select , and follow the steps as in the previous example. Once the build process is finished, choose the necessary IDE backend, which will be installed and launched within the container. To verify that the Testcontainers Cloud agent was successfully installed in your dev container, run the following in your dev container IDE terminal:  You should see a log line similar to if the agent started successfully (Figure 10). Now you can run your tests. The class contains Testcontainers-based integration tests for our application. (For more implementation details, refer to the on GitHub.) To view the containers running during the test cycle, navigate to the and check the latest session (Figure 11). You will see the name of the Service Account you created earlier in the Account line, and the Project name will correspond to the defined in the section. You can learn more about in the documentation. If you want to run the application and debug containers, you can to the cloud VM terminal and access the containers via the CLI (Figure 12). In this article, we’ve explored the benefits of using dev containers to streamline your Testcontainers-based local development environment. Using Testcontainers Cloud enhances this setup further by providing a secure, scalable solution for running Testcontainers-based containers by addressing potential security concerns and resource limitations of Docker-in-Docker approach. This powerful combination simplifies your workflow and boosts productivity and consistency across your projects. Running your dev containers in the cloud can further reduce the load on local resources and improve performance. Stay tuned for upcoming innovations from Docker that will enhance this capability even further.