Why Docker?

Docker is the most simple and clear method to isolate your services. DevOps can in significantly convenient way deploy and control their services in server environment.
Docker is nothing new but wrapper over LXC. There are two concepts when you start working with docker:

  • Docker image is what you build
  • Docker container is what you run

Docker uses layer system very similar to Version Control System. After restart container all data will be lost if not commited!
So, to run a docker container you have to create a docker image. There are two methods to create docker image. The first, you can get base docker image of your favorite linux OS, run and login to it and manually install whatever. After that commit image to save changes. It is old and hardcore way. I prefer the second one, create docker image from so called “Dockerfile” – describes all to compose image.

Example usage:

  1. Create folder “base”.
  2. Create “Dockerfile” in it with the following contents:
    FROM centos:7
    MAINTAINER "FireTrot Studio" <admin@firetrot.com>
    # ENV
    ENV container=docker
    # IMPORT
    RUN rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
    RUN yum -y install net-tools
    # RUN
    CMD ["ping", "localhost"]
  3. Build docker image with command:
    docker build -t base .
  4. Run docker container with command:
    docker run -it --name=base docker_base

And then you’ll see the output of container work.