Docker and Process Virtual Machine - docker

Is Docker (container technology) a "Process Virtual Machine"?
If different, in what ways are they different?

Related

Does docker use virtualization solution when running in linux machines?

When using Docker for Windows, the containers run side-by-side in a hyper-v linux VM on Windows.
So when launching a container in ubuntu, is any virtualization solution like hyper-v needed or are the containers just running as processes inside ubuntu?
Source for my first statement - How docker desktop runs linux containers on Windows machine
First, why hyper-v?
The reason for docker on windows using hyper-v VM just because: for a linux container, it had to share the linux kernel of host. But on windows, we do not have linux kernel, so docker set a hyper-v VM for you, then let your container to share the kernel.
Second, why not VM on linux?
But on linux, the host already has a linux kernel, so container can share this kernel without using any VM.
In fact, from next diagram you can see when you start a new container, it will auto new a process containerd-shim, it will run as a process which you can use ps aux | grep docker to see it on linux host.
And, finally, what is container?
Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container, then every process in container will run in a separated namespace. See official docementation.
"Containers" is a concept that combines (primarily) two features implemented in the Linux kernel - control groups and namespaces. You need the VM on top of Windows because Windows does not implement these two features.
Therefore, when you run containers natively on Linux, each container will simply run as separate processes constrained by control groups and namespaces.

Docker vs Virtual Machine

I have read documents that are about dockers and VMs.I guess that our environments like that dev,prod run on virtual machines in a server.Each of them runs on different virtual machine but single computer(server).Also,each virtual machine contains docker.Every docker contains containers.In this containers, application image file is hold.For example; in virtual machineB ,containerB includes image for our application.Am i right?
Can a docker contains many containers? Why we need many containers in a docker? Can anyone explain docker,virtual machine,environments and image files?How these enviroments runs server?
From https://www.docker.com/what-container:
A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it.
Docker is the service to run multiple containers on a machine (node) which can be on a vitual machine or on a physical machine.
A virtual machine is an entire operating system (which normally is not lightweight).
If you have multiple applications and those require different configurations which are in conflict with each other you can either deploy them on different machines or on the same machine using docker containers, because containers are isolated from each other.
So in short containers can make your application deployment and management easier.

Docker Host And Other Fundamental Questions

I am new to Docker. And have few easy questions hope you could help.
I have a windows 10 machine which installed "docker for windows". In its HyperV manager I could see a virtual machine called "MobyLinuxVM".
So my questions are:
1, When people talking about "Docker Host" and "Docker Engine", what are they according to my situation?
-- I assume "Docker Host" should be my windows PC, and "Docker Engine" is that Virtual machine inside Hyper-V.
2, If I use ipconfig to see my PC, I will find I got at lease 2 networks and IP addresses:
(a) Lan Adapter -- show my IP is 192.168.xxx.yyy
(b) DockerNAT -- show my IP is 10.0.75.1
Then when I try to use dock-compose.yml to create container, I found I could ONLY use:
environment:
- MAGENTO_HOST=10.0.75.2
- MARIADB_HOST=10.0.75.2
to create container and can be directly accessed (e.g. via browser to Magento website). So question is:
If my machine is 10.0.75.1 within Docker network, then what is 10.0.75.2? why I cannot use e.g. 10.0.75.3?
3, My yml script actually contains multiple containers creation -- e.g. 2 Magento containers + 2 MariaDB containers + etc. When I specify their docker 'HOST', why it's not my machine? (If we call my machine to be 'docker host' & hyper-v virtual image to be 'docker engine' in my 1st question.)
4, Also according to my 3rd question, I current deploy all containers within 1 host. Is it worth to use Docker Swarm which people can use to cluster multiple Docker hosts? If so, does that mean I need to use Hyper-V to create another "MobyLinuxVM"?
Thanks a lot!
1 Docker Engine + Docker Host
The Docker Engine is the group of processes that manage Docker containers. dockerd is usually the head of that process tree.
The Docker Host is the OS running Docker engine, that is MobyLinuxVM
Your VM host is your Windows box.
2 Docker Host IP
10.0.75.2 is most likely the address assigned to MobyLinuxVM. I don't run Docker for Windows so can't entirely confirm but searching the web seems to back this up.
3 - see 1
4 Swarm
You would need to run multiple VMs to setup swarm. Docker machine is the tool to use when setting up swarm instances. It allows you to manage multiple Docker instances and comes with a HyperV driver.

How can I make a local docker container?

I installed Docker and kitematic. I had VirtualBox before that and used many machines on Vbox. Docker is working, I can pull containers and other stuff like that. Like this link : https://docs.docker.com/mac/started/
I can add containers by:
<i> docker run docker/whalesay cowsay boo </i>
I want to know if there is any way that I can import some of my Vbox machines into docker as a Container locally?
I have ova and ovf file in my local pc. I don't wanna get involved with online containers! Is there any way to accomplish this.
Thank you.
Looks like you have some confusion on the concept of a container.
A container is not a virtual machine.
You can't import virtual machines into Docker. What you can do is build and run a Docker container which eliminates the need for a virtual machine (depending on your use case of course).
You can find a good explanation about the difference between a container and a virtual machine here.
TL;DR:
Both virtual machines and containers allow you to run multiple applications on a shared hardware.
When using virtual machines, the hardware is shared among all applications, however each application runs on a separate operating system.
When using containers, both the hardware AND the operating system are shared, and each application runs in a separate container.
This is in no way an exhaustive explanation regarding Docker containers - there are MANY more advantages to using Docker instead of a virtual machine (portability, consistency, infrastructure-as-code). This is just the main difference between them.

If docker uses virtual machine to run on a mac then what is its advantage over vagrant?

So I have read this in many places that docker is faster and more efficient because it uses containers over VMs but when I downloaded docker on my mac I realized that it uses virtual box to run the containers. I believe on a linux machine docker doesn't need virtual box and can run on Linux Kernel. Is this correct ?
Back to original question. Is docker still faster/efficient because it uses a single VM to run multiple containers as opposed to Vargrant's new VM for every environment ?
I believe on a linux machine docker doesn't need virtual box and can run on Linux Kernel. Is this correct ?
Yes, hence the need for a VirtualBox Linux VM (using a TinyCore distribution)
Is docker still faster/efficient because it uses a single VM to run multiple containers as opposed to Vargrant's new VM for every environment ?
Yes, because of the lack of Hypervisor simulating the hardware and OS: here you can launch multiple containers all using directly the kernel (through direct system calls), without having to simulate an OS.
(Note: May 2018, gVisor is another option: a container, simulating an OS!)
See more at "How is Docker different from a normal virtual machine?".
Of course, remember that Vagrant can use a docker provider.
That means you don't have to always provision a full-fledged VM with Vagrant, but rather images and containers.
Vagrant.configure("2") do |config|
config.vm.provider "docker" do |d|
d.image = "foo/bar"
end
end
See Vagrant docker provisioner.

Resources