Answer the question
In order to leave comments, you need to log in
Docker - how to understand it for a beginner?
Greetings!
I have never used docker, but at the same time I used various virtual machines quite often and I seem to understand the essence of virtualization. Also used and "sandboxes".
Very often I hear references to the docker, I read about it, I was very interested, now I'm trying to figure it out.
If I understand correctly, then docker is like a "smart" virtual machine, i.e. if you have a host on Windows 10 and you install the same Windows 10 in a container, then it will not completely install the entire system and take up a lot of disk space, but will run in an isolated container, while using system files from the host system. Like a sandbox. Those. for example, you can install three such systems, and at the same time, unlike virtual machines, this will take up very little space, because. only different files will be saved.
It seems that everything looks simple, logical and understandable, but... if I have Windows on the host and I want Ubuntu in the docker, is that not possible? Then you need a virtual machine with Ubuntu, and you need to install docker in it?
I went to a wonderful repository of images - hub.docker.
I expected to see there "ready-made images of virtual machines" for some tasks, but among other things, I saw, for example, "phpmyadmin" - this is not an OS, not an environment, but just a set of php scripts! What is in this image? After all, phpmyadmin needs a configured OS, a configured web server, a php interpreter, a database. I understand that all this "somewhere" must be, but where? Does all this download a huge image of the whole OS? Or does it all have to be on the host? Or in docker, in the parent container? Why then are some dependencies not specified, or not specified what will be downloaded with phpmyadmin?
There is generally an image for just one file: "adminer" (analogous to phpmyadmin, consisting of just one php file).Why do you need a whole image for one php file? Is it used as a particle for other images? Those. as a dependency and not as a full working image?
Please explain, I don't understand. Why is it that images with some software do not indicate which OS and what environment are needed? Or will the whole OS with all the environment be downloaded as a dependency?
Answer the question
In order to leave comments, you need to log in
Docker is not virtualization. It is a process isolation tool built on top of the Linux namespace and cgroups.
Under Windows and Mac, there are no Linux namespaces and cgroups, so you have to run containers in a virtual machine, which creates confusion.
> Why images with some software do not indicate which OS is needed
Because the image itself is built on the basis of the OS.
Those. there can be multiple images for this "some software", based on Ubuntu, Debian or (if the image is correct : ) Alpine.
Only the OS in the container tends to be heavily truncated. And yes, the kernel is used by the host machine.
> if I have Windows on the host and I want Ubuntu in the docker
Accordingly, take absolutely any image based on Ubuntu.
> if I have a Windows host,
just keep in mind that (at least until recently) Docker under Windows worked so much through ... that I, for example, to work with Docker containers, sitting under Win 10, still raise a virtual machine with Alpine, and there I already raise Docker.
Super-mega-quick guide for juniors.
There is a YouTube channel = SLURM. A must have for beginners with their school. Everything is lined up right there. I want to help you pay ATTENTION to the dockerfile - because it creates the entire config of your future stack. Accordingly, you can google and see how it is created. And after its implementation, he will receive the same phpmyadmin, linux, php, js, etc. (EXACTLY DOCKERFILE (DOCKER-COMPOSE) SERVES ALL FUTURE COMPONENTS)
And you asked there that all components are downloaded from the OS - not really, there is a stripped-down version of OC that will run only the main components, and you yourself supplement the rest through the dockerfile. For example, the same alpine weighs no more than 15 mb, and the rest of the action is like htop - you yourself throw it into the dockerfile.
If even shorter, then: Everything that you did earlier on Linux and configured for yourself - you need to throw it into the dockerfile. Suddenly you want to swap to another PC, and you have Linux in general xs where, you take the dockerfile with you and put docker on another PC and that's it. All the actions that you did for 3-6 hours are automatically compiled for you and you get your OS with settings and movement.
BUT besides the dockerfile, if you are selling "move" - most likely you will need docker-compose. Just google how one differs from the other and there will be all the available info.
Next... docker hub. It's like an app market. Everything is ready and if you don't want to deploy LAMP & WAMP, then just download one of the packages and everything starts in 2 minutes.
And the last ... If you, for example, do all this for home or you need a second OS for your tasks, and not just start the server and you're done, that is WSL2 (hello win10). You can also put ubuntu & debian & alpine there, etc.
As for me ... Docker for the window is garbage that no one needs. I don't know what to run and test there. Unless devops get experience at home ...
UPD: All your questions described in the topic - they all relate to the dockerfile. The OS is there, the stack is there, and the settings are there.
Docker only works under Linux because it works thanks to the namespace and cgroups features built into the Linux kernel.
In Windows, a virtual machine with Linux is launched, in which docker is already running.
The container means that you have one operating system kernel, but each container considers that it is the only one in the system, plus the file system adjusts to the docker image.
As a result, the operating system sees just a few running processes, and your program running in docker sees a clean OS, in which only it is running alone, and on the disk your process sees only a clean OS, the files that are actually on the disk are not visible, they must be explicitly mounted.
Since different Linuxes still use the same kernel, the images indicate what exactly is installed in Linux, and the PHP image indicates that there will be a Linux image with PHP installed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question