K
K
ksim_miloff2016-08-12 08:35:13
Docker
ksim_miloff, 2016-08-12 08:35:13

Docker as a panacea for developers?

Hello,
I'm a programmer, not a beginner, but definitely still very inexperienced :). So, for the first time in my life, I had the honor of setting up hosting for a new project. Of course, I have been able to set up a local machine for a long time, and with hosting I thought that it was not much more difficult. Hosting itself is two VPS, one for the base, the second for the application itself (production and staging). I sat, studied capistran and myself, I don’t remember how, drew attention to the docker, became interested, read several articles on Habré, a couple of articles in English, and it all seemed very promising to me. Before that, I heard about docker, but I perceived it as a virtual machine or something like a vagrant, now my understanding is somewhat better. So, I'm writing the question not with the goal of "help set up docker", but rather "help organize the information" or even "
From what I read, I got the impression that docker can do everything:

  1. docker-daemon is an HTTP server and can take over this work on the server side, i.e. nginx is not needed
  2. docker on a dev machine can (somehow) be linked to docker on a hosting
  3. and taking into account the previous point - docker can be used for deployment
  4. docker can be used to rollback if the deployment fails
  5. there is no need for any rbenv and pyenv, if another version of the language is needed, then a new container is simply created in which the installation takes place
  6. docker is very fast, incl. starts and restarts
  7. any other advantages?

Am I understanding the system correctly? Are the expectations too high?
I’m sure that I forgot a couple more goodies, but these are like the main ones, I still don’t believe that I understood everything correctly. Still in the process of reading articles and documentation. I would be grateful for a link to a detailed material for dummies.
Thank you, I hope the questions are not stupid :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tyranron, 2016-08-15
@ksim_miloff

First you need to understand "container" and "containerization".
By containerizing a process, we isolate it in our own environment, with our own personal user space. In this case, the OS kernel (kernel) during the operation of the container uses the same thing as the main OS of the machine.
The benefit here is that containers can be treated like "binaries", roughly speaking. You have some kind of application, no matter what it is, be it a set of PHP scripts, or something already compiled (postfix, nginx, apache, etc.). You pack this application and all its dependencies into a container (create an image) and at the output you get a single ready-made "something" that you can run and it does not require any more dependencies (except for container runtime - Docker, rkt, etc. .). A complete analogy with how you compile a single binary from a heap of libs and sources, which you simply then run wherever you want, without the need to have sources.
As we are used to describing and fixing source code dependencies in dependency managers (composer, bower, others), we do the same thing in the container, but for the environment of our application. Reproducibility in all fields.
This greatly simplifies life. You no longer need to worry about the fact that the application needs to accurately reproduce the environment on each machine, you have it fixed inside the container. No more conflicts between different versions of jvm, php, python, ruby, nginx etc. You can easily use on the same machine what applications you want, what versions you want. Rolling it out to another machine no longer requires filigree adjustment and coordination of the environment in accordance. Your application will no longer suddenly fall off due to misconfigured OS updates and a sudden update of dependent libs.
What about Docker?
Docker is a set of tools for working with containers.
Docker daemon is a container runtime, it starts, stops, monitors them.
Docker registry is a version control of the created images (images) of the application, by analogy with version control of the application source.
All. Conceptually, Docker and containerization give nothing more.
Answering your questions:
No. Docker daemon is a container runtime. It knows how to "listen" on certain ports, but this is done to interact with the Docker runtime, and not to perform the functionality of an HTTP server. The HTTP server is still needed, and it can (and should) be run inside a container.
We don't juggle dockers. Docker is just a container tool. We juggle containers and applications packaged in them. It makes no sense to link dockers on the hosting and on the dev machine. You create an image (image) and can run it through docker both on the dev machine and on the hosting. If you need some applications on the dev machine to communicate with others on the hosting, then this is not a docker question - it is a question of organizing communication between your applications.
IMHO, it's necessary. You have imaged the exact version of the application and its environment. It remains now to run this "binary" wherever you want.
Easily. We simply extinguish the container of the new image and raise the old one back.
Yes. In a Dockerfile, you are essentially declaring your environment exactly. We need a different environment - we change the Dockerfile and create a new image.
It is not clear - fast in what? Probably, the comparison with virtual machines means. Yes, the overhead costs are less than for virtual machines, since the same OS kernel is used. It's just that processes run in different user spaces. Otherwise, the speed of Docker is the speed of starting, in fact, the processes. If you have a heavy application with a slow start (hello FMS!) or a stop, then Docker will not help you here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question