1

So in my head, Docker is a container management system that allows you to build an application in a unified way so you don't need to worry about version control, client environment configuration and so on.

However, there is some concept that I am clearly missing:

  1. In my head, Docker basically wraps your whole program in a container to be shipped easily to clients and anybody who wants to use your product. And from there I can just tell clients to install so-and-so to set up the whole system in their own system. However, digging into Docker, I don't understand how pulling and pushing images into DockerHub helps that use case as well as not providing an executable to execute DockerImage in a click.

  2. DockerHub images take so many steps to unpack and edit. I was assuming that those templates on DockerHub exists for us to pull and edit the template for our own use cases, but that does not seem to be the case because the steps to unpack an image is much more than I imagined, and the use case seems to be more of "Download and use image, not for editing".

Surely I am missing something about Docker. What is the purpose of pushing and pulling images on DockerHub? How does that fit into the use case of containerizing my software to be executed by clients? Is the function of DockerHub images just to be pulled to be ran and not edited?

It's so hard for me to wrap my head around this because I'm assuming Docker is for containerizing my application to be easily executable by clients who wants to install my system.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Imagine you need an image of Redis. How do you get it? Right from the [DockerHub](https://hub.docker.com/_/redis), _the world's easiest way to create, manage, and deliver your teams' container applications_. It's more or less an [registry for images](https://docs.docker.com/docker-hub/). – pzaenger Nov 13 '20 at 16:43
  • Then what about images like Nodejs? Don't they serve 0 function unless written some code within them? Then that Docker image would need to be unpacked to write more source within it right? – VerenOnline Nov 13 '20 at 17:04
  • Gromulke answers that question below. Any image can be used as the starting point for your own image. Think of it as a ready-made server, and you "inherit" all the files and folders already set up. You can install more things, and copy in application code, tests, assets, or whatever you need. – halfer Nov 13 '20 at 19:26
  • Although one could use Docker for delivering software to clients, that is not the first use-case I think of. In general I use it for building development, test, and production environments under my own control. – halfer Nov 13 '20 at 19:31
  • Does this answer your question? [How is Docker different from a virtual machine?](https://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-virtual-machine) – Josh Correia May 13 '21 at 18:00

2 Answers2

2

To further explain this answer I would even say that docker allows you to have a development environment tied to your application that is the same for all your developers.

You would have your git repo with your app code, and a docker container with all that is needed to run the application.

This way, all your developers are using the same version of software and that docker container(s) should replicate the production environment (you can even deploy with it, that's another use for it) but with this there's no more the "it works on my machine" problem. Because everyone is working on the same environment.

In my case all our projects have a docker-compose structure associated with them so that each project always have their server requirements. And if one developer needs to add a new extension, he can just add it to the docker config files and all developer will receive the same extension once they update to the latest release.

marcogmonteiro
  • 2,061
  • 1
  • 17
  • 26
  • Ok, but say I have a typical React app with a Node backend and MongoDB database (or a Vue app with a Laravel backend and MySQL database, doesn't matter). What is the purpose of all of these containers on Dockerhub? I can run `create-react-app` to spin up my frontend and code out at most 15 lines in a single `server.js` file to have my full stack app up and running in 3 minutes. Why would I need a Node image? Why would I need a MongoDB image, a React image? Why complicate everything that a `package-lock.json` file would keep simple? Perhaps my understanding of "image" is incorrect? – Mike K Nov 24 '20 at 19:50
  • @MikeK You must understand that you need can be quite different than others. Some may need just the mysqlDatabase and don't need anything else. Some would need would need just the PHP and apache or nginx, others might even be working with a framework that has some requirements and someone made a docker image with all those requirements in mind. Docker allows you to just have all these options, and if you're using something like docker-compose you can even make all this, and declare some dependencies on containers with just one yml file. – marcogmonteiro Nov 24 '20 at 21:18
1

I would say there are two uses to having images on DockerHub.

The first is that some images are extremely useful as-is. Pulling a redis/mariadb image saves you the trouble of setting it and configuring it yourself.

The second is that you can think of a docker image as a layered item: assume your application is a PHP server. You can (and will have to) create an image for your app source code. BUT the container will need PHP to run your source code!

This is why you have a FROM keyword in a Dockerfile, so that you can define a "starting layer". In the case of a PHP server you'd write FROM php:latest, and docker would pull a PHP image for your server to use from DockerHub.

Without using Dockerhub, you'd have make your image from scratch, and therefore to bundle everything in your image, some operating system information, PHP, your code, etc. Having ready-to-use images to start from makes the image you're building much lighter.

  • How is adding arbitrary images of deps that are used by a project in any way useful? If I'm using MongoDB in my project, I'll need to add the npm package, add mongoose as well, and code out 5 lines of code to connect to my db on Atlas — where I'd have to do additional work, like building a cluster anyway. Why on earth would I ever need a docker image of MongoDB, if it'd be much easier to just `npm install` it and keep a working version of it in `package-lock.json`? Why not just throw my dependencies out of `package.json` altogether and use only docker images? Seems like overcomplication to me. – Mike K Nov 24 '20 at 20:02