{"id":52238,"date":"2019-11-04T00:00:00","date_gmt":"2019-11-03T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/vm-ili-docker"},"modified":"2020-02-18T13:59:55","modified_gmt":"2020-02-18T10:59:55","slug":"vm-ili-docker","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vm-ili-docker","title":{"rendered":"VM or Docker?","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>How to determine if you need Docker instead of a VM? You need to identify what exactly you want to isolate. If you need to isolate a system with guaranteed dedicated resources and virtual hardware, then you should opt for a VM. If you need to isolate running applications as separate processes within the system, you will need Docker.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h3 id=\"tak-v-chyom-zhe-otlichie-docker-konteynerov-ot-vm\">So what is the difference between Docker containers and VMs?<\/h3>\n<p><\/p>\n<p><strong>A virtual machine (VM)<\/strong> is a virtual computer with all virtual devices and a virtual hard disk, where a new independent operating system is installed along with virtual device drivers, memory management, and other components. In other words, we obtain an abstraction of physical hardware that allows us to run multiple virtual computers on a single machine.<br \/>\n<strong>An installed VM can occupy space on the computer's disk in various ways:<\/strong><\/p>\n<p><\/p>\n<ul>\n<li>fixed space on the hard disk, allowing for faster access to the virtual hard disk and avoiding file fragmentation;<\/li>\n<li>dynamic memory allocation. When additional applications are installed, memory will be dynamically allocated for them until it reaches the maximum volume allocated.<\/li>\n<\/ul>\n<p><\/p>\n<p>The more <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/vps\/\"   title=\"of virtual machines\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"2012\">of virtual machines<\/a> on the server, the more space they occupy, and they also require constant maintenance of the environment needed for your application to function.<\/p>\n<p><\/p>\n<p><strong>Docker<\/strong> is software for creating container-based applications. Containers and <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/vps\/abuzoustojchivye-vps\/\"   title=\"virtual machines\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"4214\">virtual machines<\/a> share similar advantages but operate differently. Containers take up less space as they reuse more shared resources of the host system compared to VMs, as they provide virtualization at the OS level rather than hardware level. This approach results in a smaller memory footprint, faster deployment, and easier scaling.<\/p>\n<p><\/p>\n<p>A container provides a more efficient mechanism for application encapsulation, ensuring the necessary interfaces of the host system. This capability allows containers to share the system kernel, where each container operates as a separate process of the main OS, having its own set of memory areas (its own virtual address space). Since the virtual address space of each container is unique, data belonging to different memory areas cannot be altered.<br \/>\nThe native OS for Docker is Linux (Docker can also be used on Windows and MacOS); it leverages its core benefits that allow it to organize kernel separation. Running Docker containers on Windows will occur within a virtual machine running Linux, as the containers share the host system's OS, with Linux being their primary OS.<\/p>\n<p><\/p>\n<h3 id=\"konteyner---kak-eto-rabotaet\">How does a container work?<\/h3>\n<p><\/p>\n<p><strong>Container<\/strong> \u2014 it is an abstraction at the application level that combines code and dependencies. Containers are always created from images, adding a writable top layer and initializing various parameters. Since a container has its own write layer and all changes are saved in this layer, multiple containers can share access to the same base image.<\/p>\n<p><\/p>\n<p>Each container can be configured through a file in the docker-compose project included in the main solution \u2014 docker-compose.yml. Various parameters can be set there, such as the container name, ports, IDs, resource limits, and dependencies on other containers. If the container name is not specified in the settings, Docker will create a new container each time, assigning it a random name.<\/p>\n<p><\/p>\n<p>When a container is started from an image, Docker mounts the filesystem for reading and writing over any layers below. This is where all processes we want our Docker container to execute will run. <\/p>\n<p><\/p>\n<p>When Docker first launches a container, the initial read-write layer is empty. When changes occur, they are applied to this layer; for example, if you want to modify a file, that file will be copied from the read-only layer below into the read-write layer.<br \/>\nA read-only file version will still exist, but it is now hidden under a copy. Volumes are used to store data, regardless of the container's lifecycle. Volumes are initialized when the container is created.<\/p>\n<p><\/p>\n<h3 id=\"kak-obraz-svyazan-s-konteynerom\">How is an image linked to a container?<\/h3>\n<p><\/p>\n<p><strong>Type<\/strong> \u2014 the essential element for every container. An image is created from a Dockerfile added to the project and represents a set of layered file systems stacked on top of one another, grouped together in a read-only manner; the maximum number of layers is 127.<\/p>\n<p><\/p>\n<p>At the core of every image is a base image, specified by the FROM command \u2014 the entry point when forming the Dockerfile image. Each layer is a readonly layer and is represented by a single command modifying the file system recorded in the Dockerfile.<br \/>\nTo combine these layers into a single image, Docker uses an advanced multi-layered union file system (AuFS built on top of UnionFS), allowing different files and directories from various file layers to transparently overlay, creating a cohesive file system.<\/p>\n<p><\/p>\n<p>Layers contain metadata allowing for the preservation of accompanying information about each layer during runtime and build processes. Each layer contains a reference to the next layer; if a layer has no reference, it means this is the topmost layer in the image.<\/p>\n<p><\/p>\n<p><strong>A Dockerfile can contain commands such as:<\/strong><\/p>\n<p><\/p>\n<ul>\n<li>FROM \u2014 the entry point when forming the image;<\/li>\n<li>MAINTAINER \u2014 the name of the image owner;<\/li>\n<li>RUN \u2014 executes a command during the image build;<\/li>\n<li>ADD \u2014 copies a host file into the new image; when specifying a file URL, Docker downloads it into the specified directory;<\/li>\n<li>ENV \u2014 environment variables;<\/li>\n<li>CMD \u2014 initiates the creation of a new container based on the image;<\/li>\n<li>ENTRYPOINT \u2014 the command executed when starting the container.<\/li>\n<li>WORKDIR \u2014 the working directory for executing the CMD command.<\/li>\n<li>USER \u2014 sets the UID for the container created from the image.<\/li>\n<li>VOLUME \u2014 mounts a host directory into the container.<\/li>\n<li>EXPOSE \u2014 a set of ports being listened to in the container.<\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"kak-rabotaet-unionfs\">How does UnionFS work?<\/h3>\n<p><\/p>\n<p><strong>UnionFS<\/strong> UnionFS is a service stack file system (FS) for Linux and FreeBSD. This FS implements a Copy-On-Write (COW) mechanism. The working unit of UnionFS is a layer, and each layer should be treated as a separate full-fledged file system with a directory hierarchy from the root. UnionFS creates a unified mount for other file systems and allows users to transparently merge files and directories from various file systems (referred to as branches) into a single unified file system.<\/p>\n<p><\/p>\n<p>Contents of directories with identical paths will be displayed together in a single merged directory (in a unified namespace) of the resulting file system. <\/p>\n<p><\/p>\n<p><strong>UnionFS merges layers based on the following principles:<\/strong><\/p>\n<p><\/p>\n<ul>\n<li>one layer becomes the top layer, while the second and subsequent layers become lower layers;<\/li>\n<li>users access layer objects 'top down,' meaning that if the requested object is in the 'top' layer, it will be returned, regardless of the presence of an object with the same name in the 'lower' layer; otherwise, the object from the 'lower' layer is returned; if the requested object is not found in either, an error 'No such file or directory' is returned;<\/li>\n<li>the working layer is the 'top' one, so all user actions to modify data are reflected only in the top layer, without affecting the contents of the lower layers.<\/li>\n<\/ul>\n<p><\/p>\n<p>Docker is the most widely used container technology for application development. It has become the standard in this area, built on cgroups and namespaces provided by the Linux kernel.<\/p>\n<p><\/p>\n<p>Docker allows us to quickly deploy applications and optimally utilize the file system by sharing the OS kernel among all containers, functioning as separate OS processes.<\/p>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/474068\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Docker, \u0430 \u043d\u0435 VM? \u041d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435, \u0442\u043e\u0433\u0434\u0430 \u0432\u044b\u0431\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0430\u0441\u0442\u044c \u043d\u0430 VM. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f Docker. \u0422\u0430\u043a \u0432 \u0447\u0451\u043c \u0436\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 Docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043e\u0442 VM? \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-52238","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Docker, \u0430 \u043d\u0435 VM? \u041d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vm-ili-docker\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47VM \u0438\u043b\u0438 Docker? | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Docker, \u0430 \u043d\u0435 VM? \u041d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vm-ili-docker\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-11-03T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T10:59:55+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47VM or Docker? | ProHoster","description":"How do you know whether you need Docker over a VM? You need to determine what exactly you want to isolate.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vm-ili-docker","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47VM \u0438\u043b\u0438 Docker? | ProHoster","og:description":"\u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d Docker, \u0430 \u043d\u0435 VM? \u041d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vm-ili-docker","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-11-03T21:00:00+00:00","article:modified_time":"2020-02-18T10:59:55+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"52238","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-02-09 18:02:23","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 20:47:21","updated":"2026-02-09 18:02:23","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/52238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=52238"}],"version-history":[{"count":2,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/52238\/revisions"}],"predecessor-version":[{"id":164089,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/52238\/revisions\/164089"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=52238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=52238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=52238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}