TLDR: A platform that will host your app (which is deployed as an image) and all its dependencies, which are declared in the dockerfile, the manifest that describes what your app needs to run as well as a shitload of other configurations and arguments. Dockerizing your app, saves you from the need of installing every single dependency, everywhere you wish to run it. You only need docker.
What’s so cool with it?
Let’s say you build an awesome app with Nodejs, great. Now you want to deploy it and soon enough you realize that you can’t run it because Nodejs isn’t installed on the server where you deployed your app. You install it and the app finally runs, yay! Now you try to install it again on another server which also hasn’t Nodejs installed so you install it again. See where this is going?
Your awesome app has a dependency to Nodejs. It could have more, actually apps usually have multiple dependencies, and all of them need to be present in every environment where your app would run. Docker saves you from having to install all these dependencies everywhere. Docker is the platform, which will host your app with all its dependencies, without actually installing anything in the hosting environment. The only thing that needs to be installed is Docker itself. If you have docker installed then you deploy your app as an image and you declare everything that Docker needs to know, in the manifest called .dockerfile.
I won’t get into details, but just to give you an idea of what the dockerfile could look like:
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
EXPOSE 3000
What’s the catch?
Well, there a few things.
- You add a layer of complexity and it makes debugging a bit more tricky.
- Due to bad configuration, I have experienced that apps behave differently when running on docker compared to bare bone running.
Verdict
It’s not easy, it complexes everything a little bit, but the advantage of not having to install dependencies, makes it totally worth the pain.