Connect docker compose apps

A shipping container on the back of a large whale

Locally, I use Docker and WSL2 for development. Inevitably I need to connect multiple docker compose apps, this blog post details how.

If I’m reading data from an API, I might use the public instance of an API. However, as soon as I need to create, update, or delete data, the public API doesn’t work, I switch to using a local instance.

Connect docker compose apps

Connecting multiple docker compose apps is simple as soon as you know how. I’m sure there are multiple ways to do it but the following works for me.

To ensure two or more docker compose apps can see each other, I ensure they use the same network, add the network to each of the docker-compose.yml files as below.

        external: true

Before you run each of the apps you will need to create the new network, the syntax to create a network is as below.

docker network create [network-name]

If you named your network as per my example, you would create the network as below.

docker network create

Your apps will now be able to see each other, all you need now is the URI. The URI should be the service name, if you review the Costs to Expect API docker-compose.yml file, you will see that I have set the service name as, the URI to access the API is therefore

Multiple computers, the benefit

Multiple computers can help you find more bugs in your Apps

I have a few computers that I use, most people would say too many, for me though, it works. Having multiple computers gives me the freedom to work in more than one location. I have my main desktop in my office, my old still usable desktop in my wife’s office space and two laptops, a Surface Book and a Macbook Pro. Both the Macbook Pro and Surface Book are a little long in the tooth, but they still work well enough for when I need to take a machine onsite for freelance or contract work.

Why am I mentioning I have a use multiple PCs, well, there are a whole host of development problems that you solve because you use multiple machines. Additionally, because I use multiple machines, I tend to make fewer changes to my setup than I used to. Other than my IDE of choice and Docker, my setup is simple, this makes it easier to replicate across my computers.

What is the gain?

So, what is the gain? Well, you can only use multiple PCs if your Apps are setup on each of them, this is the benefit, because you have to setup each App more than once you quickly get to spot any issues, if you added an extension when you developed a feature, boom, you’ll notice, if it isn’t easy to get your tests to run, boom you’ll notice. It also gives you the opportunity to test the first install process for your Apps, you’ll quickly notice the necessary data you added outside of a migration or the path that isn’t mapped.

Yes, having multiple computers is a luxury, the thing is though, keep your old stuff, it is more functional than you realise.

If you don’t have multiple machines, you can always use someone else’s, add an account to your partner, child’s, siblings, or parents’ computer, with their permission of course. Even if you only rarely setup one of your projects on another machine, you are bound to spot an issue you didn’t know existed.

Simpler than years ago

These days tools like Docker have solved a lot of the problems we used to experience but I still think you will find an issue or two when you setup an App fresh on another computer, especially if that App has been in development for a while or moved beyond basic functionality.