<p>Usually containers refers to something like <a href="https://www.docker.com/what-docker" rel="noreferrer">docker containers</a> which have popularized the name</p>

<p>I quote there from docker definition:</p>

<blockquote>
  <p>Using containers, everything required to make a piece of software run
  is packaged into isolated containers. Unlike VMs, containers do not
  bundle a full operating system - only libraries and settings required
  to make the software work are needed.</p>
</blockquote>

<p>The root naming comes <a href="https://en.wikipedia.org/wiki/LXC" rel="noreferrer">linux containers</a> (lxc) whose goal was to isolate a process from its host system, the first goal was to avoid compromission of the process to take over the host system.</p>

<p>Now they are used in a wider scope. In a modern 'container' definition, you'll more or less release a package for runtime which already include your application, it's underlying middle-ware if needed and all necessary libraries and be sure it will run on any compatible system.</p>

<p>The second advantage is that it allows to use multiple applications with the same dependency at different version without having to heavily tweak its environment variables so it load the correct one.</p>

<p>Unlikely to a VM system like virtual box virtual machine or an EC2 instance on AWS, containers are virtual only on the file system level and isolated only on the memory stack. They still share the same host and the operating system under them will arbitrate cpu ticks.</p>

<p>A virtual machine is virtual at the hardware level, and you run an operating system within, a container is virtual at the OS level, and your run a process within.</p>

CC BY-SA 3.0
2017-03-06T17:36:05.760Z
Hm, so something like a VirtualBox-image (or whatever that is called in VirtualBox) could also qualify as a "container", or don't I understand it?
Pierre.Vriens
CC BY-SA 3.0
2017-03-06T17:39:28.697Z
Saw I had forgot a part of the question, added the difference while extending the answer.
Tensibai
CC BY-SA 3.0
2017-03-06T17:32:53.957Z
2017-03-06T17:39:12.830Z
2017-03-06T17:39:12.830Z
Tensibai
<p>From <a href="https://aws.amazon.com/containers/" rel="nofollow noreferrer">AWS's definition</a>:</p>

<blockquote>
  <p>Containers are a method of operating system virtualization that allow
  you to run an application and its dependencies in resource-isolated
  processes. Containers allow you to easily package an application's
  code, configurations, and dependencies into easy to use building
  blocks that deliver environmental consistency, operational efficiency,
  developer productivity, and version control. Containers can help
  ensure that applications deploy quickly, reliably, and consistently
  regardless of deployment environment. Containers also give you more
  granular control over resources giving your infrastructure improved
  efficiency.</p>
</blockquote>

<p>Containerizing is packing all the essential necessities needed for doing a particular task/environment so that it is self-sufficient and can be run on any platform, which takes away a lot of pain, when it comes to setting up and installing stuff.</p>

CC BY-SA 3.0
2017-03-06T17:29:11.080Z
2017-03-06T17:33:19.967Z
2017-03-06T17:33:19.967Z
Dawny33
<p>The very first thing to know about a container is:</p>

<p>It is, first and foremost, a <strong><em>process.</em></strong></p>

<p>Once that is understood, one can start to understand how containers compare and contrast with virtual machines.  Containers and VMs both share <em>isolation</em> from their hosts.  The method of isolation is the critical difference.</p>

<p>Container processes use extensions to the OS kernel host on which they run to isolate themselves from other processes.  Other extensions also provide disk and resource isolation.  Containers <em>share</em> their kernel and memory with the host OS.</p>

<p>Virtual Machines use a <em>hypervisor</em> to isolate VMs from their hosts.  This is a layer of software that forwards requests for resources from "guests" (VMs) to the hardware.  Disk isolation is provided by disk virtualization.  VMs <em>do not</em> share a kernel with the host- they load their own kernels into memory space dedicated to the VM.</p>

<p>One important impact of this difference is that a container must be kernel-compatible with its host.  For example, it is not possible to run a Windows Nano Server-based container on a Linux host, or an Ubuntu container directly on a Windows host.  Virtual Machines, by contrast, can run any kernel regardless of host OS.  When running a Linux container on a Windows host, Docker runs the container in a Linux VM.</p>

<p>The operational differences are in agility: containers start and stop about as fast as a normal process.  VMs are "heavier," requiring dedicated resources set aside for them and take longer to start and shut down.</p>

<p>Containers offer a lot of flexibility to a DevOps operating model:</p>

<ul>
<li>Containers isolate software component dependencies.  Developers can use containers to guarantee that an application module will function as well on their development machines as in QA/UA/Production</li>
<li>Containers use software-defined networking to communicate</li>
<li>Container definitions are declarative and can be source-controlled</li>
<li>Container management systems (Kubernetes, DC/OS, Swarm) can manage hardware resource (compute/RAM/storage) pools and dynamically scale containers</li>
</ul>

CC BY-SA 3.0
2017-03-06T18:49:04.533Z
I also do your 3 last bullet point on vSphere, thanks to vagrant :)
Tensibai
CC BY-SA 3.0
2017-03-06T17:50:37.703Z
2017-03-09T06:14:36.297Z
2017-03-09T06:14:36.297Z
Dave Swersky
<p>The word <em>container</em> refers to a lightweight virtualisation technology available on modern Linux kernels, this technology is very similar to FreeBSD jails.</p>

<p>An older, non-container-able, Linux kernel is able to run processes concurrently.  Some attributes of the system are private to process, like the process environment or the process memory: only the process owning these attributes and the operating system itself are able to access to this data. (There is a lot of loopholes, like some <em>ps</em> implementations, but that's essentially true!) Some other attributes are shared among the processes, like the filesystem and network interfaces for instance.</p>

<p>A modern, container-able, Linux kernel is able to handle more attributes of the system as private data associated to a process or a group of processes. The resulting context is a <em>container</em> and instead of running a program in the “initial containers” using the filesystem and the network interfaces initialised by the operating system, it is possible to run processes in other containers, so that they see a different filesystem and a different list of network interfaces. Therefore, two processes running in distinct containers only really share the kernel.  You are maybe familiar with the <em>chroot</em> command which can run a process in a distinct file-hierarchy, containers take the idea a few step further.</p>

<p>Of course, this is just a very coarse explanation, but I hope it helps to clarify the idea of what containers are. Now, what are they good for? </p>

<p>A popular interface to the container capabilities of Linux kernels is implemented by <em>docker,</em> a command-line utility that can be used to produce artefacts representing file-systems (<em>docker images</em>) and run processes in containers where these file-systems are accessible. This software suite is also able to build ad-hoc virtual networking systems to let several containers communicate on a private network.</p>

<p>Container-based technologies are convenient to:</p>

<ul>
<li>Describe <em>scalable</em> complex deployments.</li>
<li>Provide application developers an environment very similar to the production environment.</li>
<li>Implement immutable server pattern, as software artefacts typically describe a full operating-system, not just an application package.</li>
</ul>

<p>(As you seem familiar with other virtualisation technologies like Virtual Box, you might remark that these technologies can also conveniently address the three points above. Nowadays, there is quite a small spectrum of virtualisation technologies, and we can compare the question of their popularity in certain contexts with the popularity of computer languages: it depends probably of the technical merits of each individual solution, but also to a lot of factors that I will just label “chance”.)</p>

CC BY-SA 3.0
2017-03-06T18:53:15.573Z
Not limited to Linux anymore, windows 16 has the same kind of ability
Tensibai
CC BY-SA 3.0
2017-03-06T19:45:09.213Z
Link to support my claim https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server
Tensibai
CC BY-SA 3.0
2017-03-06T18:43:13.233Z
2017-03-06T18:43:13.233Z
Michaël Le Barbier
<p>There are some questions about <strong><em><a href="https://devops.stackexchange.com/questions/tagged/containers">containers</a></em></strong>, such as:</p>

<ul>
<li><a href="https://devops.stackexchange.com/q/109/40">What role do Configuration Managment tools play in immutable infrastructure?</a></li>
<li><a href="https://devops.stackexchange.com/q/67/40">Which problems does a container orchestration solve?</a></li>
<li><a href="https://devops.stackexchange.com/q/258/40">Simple CI/CD Containers in AWS</a></li>
</ul>

<p><strong>My questions</strong>:</p>

<ul>
<li>What is actually a "container" (in the context of DevOps)?</li>
<li>Why are they used?</li>
</ul>

<terminology><containers>
What is a container?
Pierre.Vriens
# What is a container?

(Asked by: username_0 on 2017-03-06)

There are some questions about ***[containers](https://devops.stackexchange.com/questions/tagged/containers)***, such as:

* [What role do Configuration Managment tools play in immutable infrastructure?](https://devops.stackexchange.com/q/109/40)
* [Which problems does a container orchestration solve?](https://devops.stackexchange.com/q/67/40)
* [Simple CI/CD Containers in AWS](https://devops.stackexchange.com/q/258/40)

**My questions**:

* What is actually a "container" (in the context of DevOps)?
* Why are they used?

**Tags:** terminology, containers


---

## 4 answers

### Answer by username_3 on 2017-03-06. Score: 20

The very first thing to know about a container is:

It is, first and foremost, a ***process.***

Once that is understood, one can start to understand how containers compare and contrast with virtual machines. Containers and VMs both share *isolation* from their hosts. The method of isolation is the critical difference.

Container processes use extensions to the OS kernel host on which they run to isolate themselves from other processes. Other extensions also provide disk and resource isolation. Containers *share* their kernel and memory with the host OS.

Virtual Machines use a *hypervisor* to isolate VMs from their hosts. This is a layer of software that forwards requests for resources from "guests" (VMs) to the hardware. Disk isolation is provided by disk virtualization. VMs *do not* share a kernel with the host- they load their own kernels into memory space dedicated to the VM.

One important impact of this difference is that a container must be kernel-compatible with its host. For example, it is not possible to run a Windows Nano Server-based container on a Linux host, or an Ubuntu container directly on a Windows host. Virtual Machines, by contrast, can run any kernel regardless of host OS. When running a Linux container on a Windows host, Docker runs the container in a Linux VM.

The operational differences are in agility: containers start and stop about as fast as a normal process. VMs are "heavier," requiring dedicated resources set aside for them and take longer to start and shut down.

Containers offer a lot of flexibility to a DevOps operating model:

* Containers isolate software component dependencies. Developers can use containers to guarantee that an application module will function as well on their development machines as in QA/UA/Production
* Containers use software-defined networking to communicate
* Container definitions are declarative and can be source-controlled
* Container management systems (Kubernetes, DC/OS, Swarm) can manage hardware resource (compute/RAM/storage) pools and dynamically scale containers

> **Comments:**
> **username_1**: I also do your 3 last bullet point on vSphere, thanks to vagrant :)  

---

### Answer by username_4 on 2017-03-06. Score: 8

The word *container* refers to a lightweight virtualisation technology available on modern Linux kernels, this technology is very similar to FreeBSD jails.

An older, non-container-able, Linux kernel is able to run processes concurrently. Some attributes of the system are private to process, like the process environment or the process memory: only the process owning these attributes and the operating system itself are able to access to this data. (There is a lot of loopholes, like some *ps* implementations, but that's essentially true!) Some other attributes are shared among the processes, like the filesystem and network interfaces for instance.

A modern, container-able, Linux kernel is able to handle more attributes of the system as private data associated to a process or a group of processes. The resulting context is a *container* and instead of running a program in the “initial containers” using the filesystem and the network interfaces initialised by the operating system, it is possible to run processes in other containers, so that they see a different filesystem and a different list of network interfaces. Therefore, two processes running in distinct containers only really share the kernel. You are maybe familiar with the *chroot* command which can run a process in a distinct file-hierarchy, containers take the idea a few step further.

Of course, this is just a very coarse explanation, but I hope it helps to clarify the idea of what containers are. Now, what are they good for?

A popular interface to the container capabilities of Linux kernels is implemented by *docker,* a command-line utility that can be used to produce artefacts representing file-systems (*docker images*) and run processes in containers where these file-systems are accessible. This software suite is also able to build ad-hoc virtual networking systems to let several containers communicate on a private network.

Container-based technologies are convenient to:

* Describe *scalable* complex deployments.
* Provide application developers an environment very similar to the production environment.
* Implement immutable server pattern, as software artefacts typically describe a full operating-system, not just an application package.

(As you seem familiar with other virtualisation technologies like Virtual Box, you might remark that these technologies can also conveniently address the three points above. Nowadays, there is quite a small spectrum of virtualisation technologies, and we can compare the question of their popularity in certain contexts with the popularity of computer languages: it depends probably of the technical merits of each individual solution, but also to a lot of factors that I will just label “chance”.)

> **Comments:**
> **username_1**: Not limited to Linux anymore, windows 16 has the same kind of ability  
> **username_1**: Link to support my claim https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server  

---

### Answer by username_1 on 2017-03-06. Score: 7

Usually containers refers to something like [docker containers](https://www.docker.com/what-docker) which have popularized the name

I quote there from docker definition:

> Using containers, everything required to make a piece of software run
> is packaged into isolated containers. Unlike VMs, containers do not
> bundle a full operating system - only libraries and settings required
> to make the software work are needed.

The root naming comes [linux containers](https://en.wikipedia.org/wiki/LXC) (lxc) whose goal was to isolate a process from its host system, the first goal was to avoid compromission of the process to take over the host system.

Now they are used in a wider scope. In a modern 'container' definition, you'll more or less release a package for runtime which already include your application, it's underlying middle-ware if needed and all necessary libraries and be sure it will run on any compatible system.

The second advantage is that it allows to use multiple applications with the same dependency at different version without having to heavily tweak its environment variables so it load the correct one.

Unlikely to a VM system like virtual box virtual machine or an EC2 instance on AWS, containers are virtual only on the file system level and isolated only on the memory stack. They still share the same host and the operating system under them will arbitrate cpu ticks.

A virtual machine is virtual at the hardware level, and you run an operating system within, a container is virtual at the OS level, and your run a process within.

> **Comments:**
> **username_0**: Hm, so something like a VirtualBox-image (or whatever that is called in VirtualBox) could also qualify as a "container", or don't I understand it?  
> **username_1**: Saw I had forgot a part of the question, added the difference while extending the answer.  

---

### Answer by username_2 on 2017-03-06. Score: 3

From [AWS's definition](https://aws.amazon.com/containers/):

> Containers are a method of operating system virtualization that allow
> you to run an application and its dependencies in resource-isolated
> processes. Containers allow you to easily package an application's
> code, configurations, and dependencies into easy to use building
> blocks that deliver environmental consistency, operational efficiency,
> developer productivity, and version control. Containers can help
> ensure that applications deploy quickly, reliably, and consistently
> regardless of deployment environment. Containers also give you more
> granular control over resources giving your infrastructure improved
> efficiency.

Containerizing is packing all the essential necessities needed for doing a particular task/environment so that it is self-sufficient and can be run on any platform, which takes away a lot of pain, when it comes to setting up and installing stuff.


---

