

Feel free to stick it where you have your package.json. The inline comments will tell you what's what. Here's an example Dockerfile for a single Express.js node app. That's actually the default name, you can call it whatever you want, but then you'd have to specify it on the command line every time.
#WHERE DOES DOCKER INSTALL MONGO HOW TO#
The concept here is that you define how to build an image in a file named Dockerfile. You'll see that happening when we get to Docker Compose (basically managing multiple containers). You can get them to talk through your host, or create a private bridge network so they can talk directly to each other. Now, your containers can talk to each other, but only if you allow it. All your containers can run on a single computer, or you can spread them across many. Need more than one instance of your microservice running? Then you run multiple containers. But it's a cut-down version with just the bare minimum for you to do just what you need.

That's what keeps them lightweight.įor example, you can use an Ubuntu 16.04 image. What environment you say? Well, it's just the essential programs needed to run your app. Not photographs, but a snapshot of a prebuilt environment. You get the picture.Ĭontainers are created from images. Each Node.js microservice? In their own containers. Your Express.js API server? In its own container. Each process is run in its own container. Magic! So how does Docker work?ĭocker containers are basically a running version of your app. The benefit means I can create runnable versions of the whole stack, check the build and run configuration into my git repository, then run them from one simple command docker-compose up. But I also wanted other developers in my team to do it as well.ĭocker was the solution. Up until now I would spin up a VirtualBox VM and have my dev environment all contained within it.īut when I started building node apps split over different microservices, sharing a Redis backed queue manager and a MongoDB database, I realised I needed a simple way to start and stop this 'production-like' environment on my development machine. It took me a long time to really figure out the benefits of using Docker. Let me tell you how to dockerize your app in ~2 minutes. You've got a node app, it has a web server, a microservice, needs a database and uses Redis as a message queue for the microservice.
