Skip to content

Running the Stack

We now have a compose.yaml file that describes both services.

Time to cash in.

Instead of launching containers one at a time with a pile of manual commands, we can now ask Docker Compose to bring the whole stack up for us.

From the folder containing compose.yaml, run:

Terminal window
docker compose up

Compose will read the file, build what needs to be built, pull what needs to be pulled, create the network, and start the services.

That is already a lot less nonsense than the manual approach.

By default, docker compose up keeps the logs attached to our terminal. This is exactly what we want right now.

We can watch both services start in real time and, more importantly, spot connection issues immediately as they scroll past.

Watch the Output

When we are still figuring out what is happening, attached logs are our friend.

They make the system feel much less mysterious.

If this is our first run, Compose may need a moment to:

  • build the API image
  • download the MongoDB image
  • create the containers
  • create the network

Once the logs settle and we see the API is listening, we can test it at:

http://localhost:3000/api/projects

At this point, Compose has made startup much easier.

But we still have one important issue floating around in the background:

  • Our app code is still hardcoded to connect to MongoDB in a way that belongs in configuration, not in source code.

So yes, Compose improves orchestration immediately.

But no, we are not fully cleaned up yet.

Easy Startup Does Not Automatically Mean Good Configuration

Compose can start the stack beautifully, but it does not magically fix bad configuration choices inside our app.

If important values are still hardcoded, we still have work to do.

Now that we have seen the power of “one command to rule them all,” we need to make that command smarter by stripping out the hardcoded secrets and connection strings.


Docker Compose Up Reference

Compose now manages the stack, but our configuration still needs work. Next, we’ll clean up service settings and move important values into environment-based config.