Skip to main content

Docker, explained.

Published 2021/04/14 16:20

So you've just built a project. Let's say it's a to-do app. There are plenty of things involved:

  • front-end
  • back-end
  • database…

For your project, you're using React as front end, Python with Flask as a backend API, and MySQL as a database.

You're also using Mac as your main operating system on your computer for developing and testing your app locally.

Anything you download for your app has been tailored for the operating system you're using.

Now you talk to your friend about this app you're building and he seems pretty excited to try it out! Thing is, it's not hosted anywhere at the moment so it's only available locally.

So you need to tell your friend that he needs to get the code from Github, then download the necessary stuff in order to run the app: Node, Python, MySQL etc.

So your friend, who is running Ubuntu, goes ahead and installs the necessary tools to run your to-do app.

Once everything is up and running, your friend tries to run your to-do app. But… he fails. WHY? WHAT IS GOING ON?

After days of investigation, you find out that you're running different versions of MySQL and different versions of Node. It turns out, this is because you're running different operating systems!

After days of debugging, painful googling and comparing versions, you finally manage to get your to-do app up and running on his machine.

What if there was an easier way to do this? What if you could just have one version of each tool, or even the operating system, put it into a little package and send it to anyone who wants to run your app straight away? And it would run correctly every time without the hassle?

Enter Docker!

Docker is a tool that helps you grab everything, from the operating system, to all the frameworks, tools and libraries you might need and put them into little packages called "containers".

These packages are created so you can easily take them wherever you want. Either give it to your friend to try your app, for a colleague to be able to develop using the same environment, or even put it on a server.

You can feel confident that no matter where you put the container, whichever operating system or environment, the app will work the same way!

In the case of your app, with Docker, you can create a container, add a specific version of Linux, install the latest version of Python, the latest version of Node and the latest version of MySQL. You can give the container to your friend and he will have all the same versions!

To get started with your first container is quite simple too! First install Docker see here, open a terminal and type this:

docker run -it ubuntu 

The command will create a new container which has Ubuntu as the operating system.

The first time you run it, it will take a while until it it downloads the stuff necessary to run Ubuntu, or the Ubuntu "image". Now you can run commands just like you would in a normal Ubuntu installation! Give it a go!

You can find lots of ready-made "images" for various tools such as Node, Python, MySQL etc. in the Docker Hub.

Check it out here

Enjoy using Docker and its countless capabilities!

Dev, Explained (43 part series)

  1. Javascript Scopes, explained.
  2. Javascript Promises, explained.
  3. Accessibility, explained.
  4. React, explained
  5. Should I use forEach() or map()?
  6. Should I use Flexbox or CSS Grid?
  7. Docker, explained.
  8. Unit testing, explained
  9. Git, explained.
  10. Typescript, explained.
  11. async/await, explained.
  12. The DOM, explained.
  13. Regular expressions, explained
  14. GraphQL, explained.
  15. Vue, explained.
  16. Svelte, explained.
  17. API, explained.
  18. Javascript Hoisting, explained.
  19. Immediately Invoked Function Expressions (IIFE), explained.
  20. ARIA roles, explained.
  21. Test-driven Development, explained.
  22. ARIA live regions, explained.
  23. aria-label in accessibility, explained.
  24. Type coercion in Javascript, explained.
  25. Variables, explained.
  26. if statements, explained.
  27. Arrays, explained.
  28. Currying in Javascript, explained.
  29. Memoization, explained.
  30. For loops, explained.
  31. Javascript Prototypes, explained.
  32. React Hooks, explained.
  33. Graph databases, explained.
  34. MongoDB, explained.
  35. Serverless, explained.
  36. Javascript Callback functions, explained.
  37. HTML, explained.
  38. CSS, explained.
  39. Responsive design, explained.
  40. Javascript, explained.
  41. The CSS Box Model, explained.
  42. CSS Flexbox, explained.
  43. CSS Grid, explained.
2022 Savvas Stephanides
Buy me a coffee
Some icons from Freepik