Docker, what is it and what is the purpose
NickName:mfrachet Ask DateTime:2015-01-22T20:56:18

Docker, what is it and what is the purpose

I've heard about Docker some days ago and wanted to go across.

But in fact, I don't know what is the purpose of this "container"?

What is a container?

Can it replace a virtual machine dedicated to development?

What is the purpose, in simple words, of using Docker in companies? The main advantage?

Copyright Notice:Content Author:「mfrachet」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28089344/docker-what-is-it-and-what-is-the-purpose

Answers
GorvGoyl 2017-02-08T11:04:04

VM: Using virtual machine (VM) software, for example, Ubuntu can be installed inside a Windows. And they would both run at the same time. It is like building a PC, with its core components like CPU, RAM, Disks, Network Cards etc, within an operating system and assemble them to work as if it was a real PC. This way, the virtual PC becomes a "guest" inside an actual PC which with its operating system, which is called a host.\nContainer: It's same as above but instead of using an entire operating system, it cut down the "unnecessary" components of the virtual OS to create a minimal version of it. This lead to the creation of LXC (Linux Containers). It therefore should be faster and more efficient than VMs.\nDocker: A docker container, unlike a virtual machine and container, does not require or include a separate operating system. Instead, it relies on the Linux kernel's functionality and uses resource isolation.\nPurpose of Docker: Its primary focus is to automate the deployment of applications inside software containers and the automation of operating system level virtualization on Linux. It's more lightweight than standard Containers and boots up in seconds.\n\n(Notice that there's no Guest OS required in case of Docker)",


BMitch 2017-12-13T01:23:10

[ Note, this answer focuses on Linux containers and may not fully apply to other operating systems. ]\n\n\n What is a container ?\n\n\nIt's an App: A container is a way to run applications that are isolated from each other. Rather than virtualizing the hardware to run multiple operating systems, containers rely on virtualizing the operating system to run multiple applications. This means you can run more containers on the same hardware than VMs because you only have one copy of the OS running, and you do not need to preallocate the memory and CPU cores for each instance of your app. Just like any other app, when a container needs the CPU or Memory, it allocates them, and then frees them up when done, allowing other apps to use those same limited resources later.\n\nThey leverage kernel namespaces: Each container by default will receive an environment where the following are namespaced:\n\n\nMount: filesystems, / in the container will be different from / on the host.\nPID: process id's, pid 1 in the container is your launched application, this pid will be different when viewed from the host.\nNetwork: containers run with their own loopback interface (127.0.0.1) and a private IP by default. Docker uses technologies like Linux bridge networks to connect multiple containers together in their own private lan.\nIPC: interprocess communication\nUTS: this includes the hostname\nUser: you can optionally shift all the user id's to be offset from that of the host\n\n\nEach of these namespaces also prevent a container from seeing things like the filesystem or processes on the host, or in other containers, unless you explicitly remove that isolation.\n\nAnd other linux security tools: Containers also utilize other security features like SELinux, AppArmor, Capabilities, and Seccomp to limit users inside the container, including the root user, from being able to escape the container or negatively impact the host.\n\nPackage your apps with their dependencies for portability: Packaging an application into a container involves assembling not only the application itself, but all dependencies needed to run that application, into a portable image. This image is the base filesystem used to create a container. Because we are only isolating the application, this filesystem does not include the kernel and other OS utilities needed to virtualize an entire operating system. Therefore, an image for a container should be significantly smaller than an image for an equivalent virtual machine, making it faster to deploy to nodes across the network. As a result, containers have become a popular option for deploying applications into the cloud and remote data centers.\n\n\n Can it replace a virtual machine dedicated to development ?\n\n\nIt depends: If your development environment is running Linux, and you either do not need access to hardware devices, or it is acceptable to have direct access to the physical hardware, then you'll find a migration to a Linux container fairly straight forward. The ideal target for a docker container are applications like web based API's (e.g. a REST app), which you access via the network.\n\n\n What is the purpose, in simple words, of using Docker in companies ? The main advantage ?\n\n\nDev or Ops: Docker is typically brought into an environment in one of two paths. Developers looking for a way to more rapidly develop and locally test their application, and operations looking to run more workload on less hardware than would be possible with virtual machines.\n\nOr Devops: One of the ideal targets is to leverage Docker immediately from the CI/CD deployment tool, compiling the application and immediately building an image that is deployed to development, CI, prod, etc. Containers often reduce the time to move the application from the code check-in until it's available for testing, making developers more efficient. And when designed properly, the same image that was tested and approved by the developers and CI tools can be deployed in production. Since that image includes all the application dependencies, the risk of something breaking in production that worked in development are significantly reduced.\n\nScalability: One last key benefit of containers that I'll mention is that they are designed for horizontal scalability in mind. When you have stateless apps under heavy load, containers are much easier and faster to scale out due to their smaller image size and reduced overhead. For this reason you see containers being used by many of the larger web based companies, like Google and Netflix.",


Siyaram Malav 2019-12-10T17:00:26

Same questions were hitting my head some days ago and what i found after getting into it, let's understand in very simple words.\n\nWhy one would think about docker and containers when everything seems fine with current process of application architecture and development !!\n\nLet's take an example that we are developing an application using nodeJs , MongoDB, Redis, RabbitMQ etc services [you can think of any other services].\nNow we face these following things as problems in application development and shipping process if we forget about existence of docker or other alternatives of containerizing applications.\n\nCompatibility of services(nodeJs, mongoDB, Redis, RabbitMQ etc.) with OS(even after finding compatible versions with OS, if something unexpected happens related to versions then we need to relook the compatibility again and fix that).\n\nIf two system components requires a library/dependency with different versions in application in OS(That need a relook every time in case of an unexpected behaviour of application due to library and dependency version issue).\n\nMost importantly , If new person joins the team, we find it very difficult to setup the new environment, person has to follow large set of instructions and run hundreds of commands to finally setup the environment And it takes time and effort.\nPeople have to make sure that they are using right version of OS and check compatibilities of services with OS.And each developer has to follow this each time while setting up.\n\nWe also have different environment like dev, test and production.If One developer is comfortable using one OS and other is comfortable with other OS And in this case, we can't guarantee that our application will behave in same way in these two different situations.\n\n\nAll of these make our life difficult in process of developing , testing and shipping the applications.\nSo we need something which handles compatibility issue and allows us to make changes and modifications in any system component without affecting other components.\n\nNow we think about docker because it's purpose is to\ncontainerise the applications and automate the deployment of applications and ship them very easily.\n\n\nHow docker solves above issues-\n\nWe can run each service component(nodeJs, MongoDB, Redis, RabbitMQ) in different containers with its own dependencies and libraries in the same OS but with different environments.\n\nWe have to just run docker configuration once then all our team developers can get started with simple docker run command, we have saved lot of time and efforts here:).\n\n\n\nSo containers are isolated environments with all dependencies and\nlibraries bundled together with their own process and networking\ninterfaces and mounts.\nAll containers use the same OS resources\ntherefore they take less time to boot up and utilise the CPU\nefficiently with less hardware costs.\n\nI hope this would be helpful.",


Rafiq 2021-03-21T13:45:11

Why use docker:\nDocker makes it really easy to install and running software without worrying about setup or dependencies. Docker is really made it easy and really straight forward for you to install and run software on any given computer not just your computer but on web servers as well or any cloud based computing platform. For example when I went to install redis in my computer by using bellow command\nwget http://download.redis.io/redis-stable.tar.gz\nI got error,\n\nNow I could definitely go and troubleshoot this install that program and then try installing redis again, and I kind of get into endless cycle of trying to do all bellow troubleshooting as you I am installing and running software.\n\nNow let me show you how easy it is to run read as if you are making use of Docker instead. just run the command docker run -it redis, this command will install docker without any error.\n\nWhat docker is:\nTo understand what is docker you have to know about docker Ecosystem.\n\nDocker client, server, Machine, Images, Hub, Composes are all projects tools pieces of software that come together to form a platform where ecosystem around creating and running something called containers, now if you run the command docker run redis something called docker CLI reached out to something called the Docker Hub and it downloaded a single file called an image.\nAn image is a single file containing all the dependencies and all the configuration required to run a very specific program, for example redis this which is what the image that you just downloaded was supposed to run.\nThis is a single file that gets stored on your hard drive and at some point time you can use this image to create something called a container.\n\nA container is an instance of an image and you can kind of think it as being like a running program with it's own isolated set of hardware resources so it kind of has its own little set or its own little space of memory has its own little space of networking technology and its own little space of hard drive space as well.\nNow lets examine when you give bellow command:\nsudo docker run hello-world\nAbove command will starts up the docker client or docker CLI, Docker CLI is in charge of taking commands from you kind of doing a little bit of processing on them and then communicating the commands over to something called the docker server, and docker server is in charge of the heavy lifting when we ran the command Docker run hello-world,\n\nThat meant that we wanted to start up a new container using the image with the name of hello world, the hello world image has a tiny tittle program inside of it whose sole purpose or sole job is to print out the message that you see in the terminal.\nNow when we ran that command and it was issued over to the docker server a series of actions very quickly occurred in background. The Docker server saw that we were trying to start up a new container using an image called hello world.\nThe first thing that the docker server did was check to see if it already had a local copy like a copy on your personal machine of the hello world image or that hello world file.So the docker server looked into something called the image cache.\n\nNow because you and I just installed Docker on our personal computers that image cache is currently empty, We have no images that have already been downloaded before.\nSo because the image cache was empty the docker server decided to reach out to a free service called Docker hub. The Docker Hub is a repository of free public images that you can freely download and run on your personal computer. So Docker server reached out to Docker Hub and and downloaded the hello world file and stored it on your computer in the image-cache, where it can now be re-run at some point the future very quickly without having to re-downloading it from the docker hub.\nAfter that the docker server will use it to create an instance of a container, and we know that a container is an instance of an image, its sole purpose is to run one very specific program. So the docker server then essentially took that image file from image cache and loaded it up into memory to created a container out of it and then ran a single program inside of it. And that single programs purpose was to print out the message that you see.\nWhat a container is:\n\nA container is a process or a set of processes that have a grouping of resource specifically assigned to it, in the bellow is a diagram that anytime that we think about a container we've got some running process that sends a system call to a kernel, the kernel is going to look at that incoming system call and direct it to a very specific portion of the hard drive, the RAM, CPU or what ever else it might need and a portion of each of these resources is made available to that singular process.",


Joel H 2019-07-01T11:38:20

Let me try to provide as simple answers as possible:\n\n\n But in fact, I don't know what is the purpose of this \"container\"?\n\n\nWhat is a container?\n\nSimply put: a package containing software. More specifically, an application and all its dependencies bundled together. A regular, non-dockerised application environment is hooked directly to the OS, whereas a Docker container is an OS abstraction layer. \n\nAnd a container differs from an image in that a container is a runtime instance of an image - similar to how objects are runtime instances of classes in case you're familiar with OOP. \n\n\n Can it replace a virtual machine dedicated to development?\n\n\nBoth VMs and Docker containers are virtualisation techniques, in that they provide abstraction on top of system infrastructure.\n\nA VM runs a full “guest” operating system with virtual access to host resources through a hypervisor. This means that the VM often provides the environment with more resources than it actually needs In general, VMs provide an environment with more resources than most applications need. Therefore, containers are a lighter-weight technique. The two solve different problems. \n\n\n What is the purpose, in simple words, of using Docker in companies?\n The main advantage?\n\n\nContainerisation goes hand-in-hand with microservices. The smaller services that make up the larger application are often tested and run in Docker containers. This makes continuous testing easier. \n\nAlso, because Docker containers are read-only they enforce a key DevOps principle: production services should remain unaltered \n\nSome general benefits of using them:\n\n\nGreat isolation of services\nGreat manageability as containers contain everything the app needs\nEncapsulation of implementation technology (in the containers)\nEfficient resource utilisation (due to light-weight os virtualisation) in comparison to VMs\nFast deployment \n",


j4jada 2021-11-25T05:13:11

If you don't have any prior experience with Docker this answer will cover the basics needed as a developer.\nDocker has become a standard tool for DevOps as it is an effective application to improve operational efficiencies. When you look at why Docker was created and why it is very popular, it is mostly for its ability to reduce the amount of time it takes to set up the environments where applications run and are developed.\nJust look at how long it takes to set up an environment where you have React as the frontend, a node and express API for backend, which also needs Mongo. And that's just to start. Then when your team grows and you have multiple developers working on the same front and backend and therefore they need to set up the same resources in their local environment for testing purposes, how can you guarantee every developer will run the same environment resources, let alone the same versions? All of these scenarios play well into Docker's strengths where it's value comes from setting containers with specific settings, environments and even versions of resources. Simply type a few commands to have Docker set up, install, and run your resources automatically.\nLet's briefly go over the main components. A container is basically where your application or specific resource is located. For example, you could have the Mongo database in one container, then the frontend React application, and finally your node express server in the third container.\nThen you have an image, which is from what the container is built. The images contains all the information that a container needs to build a container exactly the same way across any systems. It's like a recipe.\nThen you have volumes, which holds the data of your containers. So if your applications are on containers, which are static and unchanging, the data that change is on the volumes.\nAnd finally, the pieces that allow all these items to speak is networking. Yes, that sounds simple, but understand that each container in Docker have no idea of the existence of each container. They're fully isolated. So unless we set up networking in Docker, they won't have any idea how to connect to one and another.",


More about “Docker, what is it and what is the purpose” related questions

Docker, what is it and what is the purpose

I've heard about Docker some days ago and wanted to go across. But in fact, I don't know what is the purpose of this "container"? What is a container? Can it replace a virtual machine dedicated...

Show Detail

What is the purpose of Docker-compose and Portainer?

I am an engineering newbie who is trying to learn something while experimenting with Raspberry Pi. I wanted to try out Docker, so I followed along with a tutorial, which installed Docker, docker-co...

Show Detail

What is the purpose of Docker-compose and Portainer?

I am an engineering newbie who is trying to learn something while experimenting with Raspberry Pi. I wanted to try out Docker, so I followed along with a tutorial, which installed Docker, docker-co...

Show Detail

What is the purpose of Docker?

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 an...

Show Detail

What is the purpose of the Docker build context?

What is the purpose of the Docker build context? I understand, from the documentation, that it's the "entry" point from which the entire contents will be sent to the docker daemon. But what's the p...

Show Detail

What is the purpose of prepending the folder name to container name in docker compose

I have my docker compose file in /documents folder and when I use docker-compose up, it appends the folder name to the service name (myappv1). documents_myappv1_1 What is the purpose of this? Why ...

Show Detail

What's the purpose of reexec.Init() in docker?

When reading the source code of docker1.8, I find that reexec.Init() appears in docker.go,dockerinit.go and some test files. If reexec has registered functions, then reexec.Init() will return tr...

Show Detail

What is the purpose of building a docker image inside a compose file?

I was reading Quickstart: Compose and Django when I came across "defining a build in a compose file". Well I've seen it before but what I'm curious about here is what's the purpose of it? I

Show Detail

In docker-compose, what is the effect/purpose of `dns-search: .`

I am looking at the stackstorm docker-compose file, and within it almost all containers have a line dns_search: . According to docker-compose documentation, dns_search is for the purpose of configu...

Show Detail

What is the purpose of running a django application in a virtualenv inside a docker container?

What is the purpose of virtualenv inside a docker django application? Python and other dependencies are already installed, but at the same time it's necessary to install lots of packages using pip,...

Show Detail