VScode: How to Chain Multiple Devcontainer for Development
Tags: docker, vscode, devops, programming
Published: 2024-06-04 14:00:00

## Introduction

Hello, I am Ise, an engineer at WESEEK who is in charge of the development and operation of [GROWI.cloud](https://growi.cloud/?utm_source=dev+community&utm_medium=referral&utm_campaign=VScode_How_to_Chain_Multiple_Devcontainer_for_Development).

In this issue, I would like to share a story about a time when I encountered a troubling problem in the development of GROWI.cloud and solved it.

---

## Background

- GROWI.cloud develops mainly in node.js, and its projects are divided into “Project A”, “Project B” and so on, according to their roles.
- GROWI.cloud's services are made possible by these “Project A” and “Project B” communicating with each other.
- Recently, we have decided to use VSCode's devcontainer(, docker-compose) for our development environment.
- The devcontainer change had no impact on the development of individual projects, as they were all linked with other projects using the internal test environment.
- However, when “Project A” and “Project B” were developed, the devcontainers of both projects could not communicate with each other and hindered the development.
- Therefore, I reviewed the settings around the network of devcontainer, and decided to improve the development environment to enable communication between multiple devcontainers.

---

## What I did

- **Add a setting that allows the network to be specified when the docker-compose of devcontainer is started**

Thus, when devcontainer is built, if there is no Docker network, it will be created automatically.

![Setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mq7kqh8m1iuzycrgk8rv.png)

_*By adding the same configuration to Project B, it is possible to connect to the same namespace network regardless of whether devcontainer of Project A or B is started first._

On the same Docker network, you can resolve names by service name

- **Fix service names in devcontainer/docker-compose.yml so that they are not covered by Projects A and B**

_*Service names in the same Docker network cannot be resolved correctly if they are the same, so even if they are different projects, it is necessary to make sure that the service names do not overlap._

![Fix service names](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0m1g5wrvm5xcxzaefdty.png)

Now you can name resolve node.js apps in Project A as node, node.js apps in Project B as node-project-b, and so on!

- **Set network in .devcontainer/docker-compose.yml to connect to the same network**

![Set network1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17asogjdy74ylmlm5lyk.png)

![Set network2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhquwyqh1llhkyub9xvu.png)

- **Review correspondence destination**

_*Before devcontainerization, the communication destination was sorted by “port number” of localhost, but now it is possible to communicate by specifying the service name, so it has been modified._

_example: When sending a POST request from Project A to Project B_

![Review](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pznt82ktk9iete9qzogx.png)

- **Rebuild container**

![Rebuild Container](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfkx9fid1hsd0xp6fvni.png)

That's all I did!
Hope everyone has a good devcontainer LIFE!

---

## About Us💡

In addition, we want to introduce a little more about GROWI, an open software developed by **WESEEK, Inc**.

**GROWI** is a wiki service with features-rich support for efficient information storage within the company. It also boasts high security and various authentication methods are available to simplify authentication management, including **LDAP/OAuth/SAML**.

**GROWI** originated in Japan and GROWI OSS is **FREE** for anyone to [download](https://docs.growi.org/en/admin-guide/?utm_source=dev+community&utm_medium=referral&utm_campaign=VScode_How_to_Chain_Multiple_Devcontainer_for_Development) and use **in English**.

For more information, go to [GROWI.org](https://growi.org/en/?utm_source=dev+community&utm_medium=referral&utm_campaign=VScode_How_to_Chain_Multiple_Devcontainer_for_Development) to learn more about us. You can also follow our [Facebook](https://www.facebook.com/people/GROWIcloud/100089272547238/) to see updates about our service.

![GROWI.org](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt1jaui0iudzecbfst0w.png)