Difference between Docker and OpenVZ

26,877

The perspective on containers is very different between the 2.

In short OpenVZ sees a container as a VPS, and docker sees a container as an application/service.

What does this imply? For OpenVZ you can expect that when you create containers, its sort of like making Virtual Servers. OpenVZ has interfaces focussed on setting up VPS containers that you decorate yourself manually. Therefore they provide templates for empty linux machines that you can start up and shut down, that you afterward SSH into, to set them up yourself with whatever you need, like a LAMP stack.

When you would want to set up a LAMP stack, you would do it like you usually do when you set up a new server. You get an empty linux machine with a virtual ethernet adapter that has its own publicly accessible WAN IP with Ubuntu on it, access it with SSH, and you install all required services in it using your average package manager (yum or apt) and do the setup required in config files yourself.

For Docker, you can expect that when you create containers, the container is a single application, that just does ONE thing. Hence, it might need some other containers to help it. (For example a container that provides a database) Docker made it very easy to define whats inside a container without having to actually start one up, and constantly create new exactly equals instances of this container. They define the contents of a docker container (the image) by using very lightweight templates that they call Dockerfiles.

There is a huge set of dockerfiles already out there, that you can find in the Docker hub, take a look yourself (its like being in a candy shop with free candy! :D): docker hub. The images produced by these dockerfiles can be pulled with the docker CLI tool, by using a pull command. In docker theres also easy access to stuff like port forwarding, virtual directories (so that you can acces files on the host machine easily) and things alike that any executable could use.

If you would want a LAMP stack in docker, all you do is "docker run -d -p 80:80 tutum/lamp"

This pulls the image tutum/lamp, and runs daemonised (-d) it with port 80 from the container forwarded to the port 80 of the host, exposing the inner webservice to the outside. As you can see, it does not have its own IP address in contrast to an OpenVZ machine. And its just like its an apache server running on your root machine. The advantage compared to installing it natively, is that docker makes the installation a lot easier and unlimitedly replicable. Also it doesn't clutter your host machine with lots of files, and supplies a security boundary around your application.

Theres lots of features in most docker images, that are unique to it. For the tutum/lamp image, take a look here.

Share:
26,877
forum.test17
Author by

forum.test17

Updated on July 28, 2022

Comments

  • forum.test17
    forum.test17 almost 2 years

    I am newbie to the world of virtualization. Can some one explain to me the differences between OpenVZ and Docker?

    What could be good for the future?

    Pros and cons?

  • forum.test17
    forum.test17 about 9 years
    Thank you so much for the detailed answer :). I have few doubts. Consider a setup Where I need a mysql server and tomcat apache with two network cards. This can be easily achieved in openVZ as it is virtual server and I can create as many virtual private servers in the same machine. How would I achieve this Docker ?
  • forum.test17
    forum.test17 about 9 years
    for some one who want to know more about linux containers and docker read this stackoverflow.com/questions/16047306/…
  • RoyB
    RoyB about 9 years
    Your setup could be achieved in both solutions. When you choose for docker, you would just forward the ports of the containerized services so that it looks as if they're hosted from the docker host. Also, you could choose to link the containers to eachother, so that you dont need to expose your database to the web. I'd personally go for docker, there is a learning curve, but in the end its far easier to set up and install applications with. You'll definitely fall in love with Docker within days I bet.
  • forum.test17
    forum.test17 about 9 years
    thanks for the inputs can you give me links to start of with. I have read somewhere that I cannot run mysql server instances in docker and cannot have 2 ethernet interfaces from this github.com/docker/docker/issues/1824. Is it still not possible to achieve this.
  • RoyB
    RoyB about 9 years
    1) You should not want to have 2 ethernet interfaces: Use port forwarding instead. If you want to use domain name's for each docker, you could use a reverse proxy with FQDN based forwarding. Feels much like virtual hosts on a web server... 2) docker.com/tryit
  • forum.test17
    forum.test17 about 9 years
    What if I need two interfaces ?
  • RoyB
    RoyB about 9 years
    What do you need two interfaces for? Can you sketch your underlying needs?
  • forum.test17
    forum.test17 about 9 years
    honestly I don't know what is used for . I am doing the background study regarding virtualisation which supports two interface cards
  • RoyB
    RoyB about 9 years
    Sorry to rock your socks, but containerisation has nothing to do with virtualisation, it is rather an alternative to virtualisation. It works by restricting the execution context of a specific set of applications from within the unix kernel. The underlying technology is called LXC/Linux Control Groups (google that!)
  • Alec Istomin
    Alec Istomin almost 9 years
    Great answer! I'd add that OpenVZ creates a "funky" VM (with phsyical server like properties, init scripts, filesystem, network interfaces, mount points, etc) that doesn't have a dedicated kernel. While docker launches a bunch of services isolated from the host until you stop it. Don't be suprrised when your container's FS is gone when you stop a docker container (although there are ways to persist, it's not the default intention with docker)