Breakdown Docker

Docker is a tool for building environments and installing software on target systems. Here is a simple overview of what Docker is and a simple example.

Docker Explained

Docker is a key component of any devops or other automated build process. It’s like Puppet or Chef, which are tools for pushing out builds.  Those let you write a script to do things like configure virtual networks, install software, and run commands.

Docker is small and simple.  So, you can easily do a small test to see how it works and how you might use it.  We show you how to do that here.

[See Also: Continuous Delivery with Docker]

Docker is a small Linux, Mac, or Windows container (image) to which you can add commands.  So it’s like a tiny little Linux, Mac, or Windows OS that you can use to do something like install and configure Hadoop or Nginx on a target server. You run that image from the command line of any those operating systems.

The container is necessary because installing Hadoop or Apache or anything like that requires an operating system. But what Docker does it lets you do is abstract that layer so that it can run anywhere. That’s consistent with the Devops philosophy of Infrastructure as Code.

Docker is best illustrated with a small example.  Here we will create the smallest possible Docker program, the Hello World program.

Installing Docker

First, you install Docker.  There are several different ways to do that, but on Ubuntu we used this:

sudo curl -fsSL https://get.docker.com/ | sh

They make sure it is running by checking:

ps -ef | grep docker

Note: If you get any errors related to TLS when you are running Docket then either Docker is not running or you need to use sudo to run it as root. You can use sudo usermod -aG docker (username) to add a user to the Docker group so that they can run that.

[See Also: Making a Case for Continuous Testing in a DevOps Environment]

Docker Hello World

Now create a directory and create a file there called Dockerfile. Copy the contents of the next two lines into
that.

FROM busybox

RUN echo “Hello World!”

The first line means the base image to use.  We could have used, for example, Ubuntu.  But that is large (about 64 MB) and we do not need a full base image to do a simple Hello Word.  So we use the smallest possible base image BusyBox.

The second command is the RUN command.  Here we just run the Linux command echo. We could have done something else like RUN apt-get (something).

When we run it:

sudo docker build -t helloword .

It looks like this:

Sending build context to Docker daemon 2.048 kB

Step 1 : FROM busybox

latest: Pulling from library/busybox

385e281300cc: Pull complete

a3ed95caeb02: Pull complete

Digest:

sha256:4a887a2326ec9e0fa90cce7b4764b0e627b5d6afcb81a3f73c
85dc29cea00048

Status: Downloaded newer image for busybox:latest

—> 47bcc53f74dc

Step 2 : RUN echo “Hello World!”

—> Running in 0218e43aedd8

Hello World!

—> 737ed2d177f9

Removing intermediate container 0218e43aedd8

Successfully built 737ed2d177f9

Docket downloads the Busybox image and runs our simple command.  It also has now created a Docker image that we can see with sudo docker images.

The -t helloword creates a tag (image name). The period (.) means look for the Dockerfile in the current folder.

Next Steps

If this example seems simplistic, it is, but that was our goal.  RUN is just one command.  There are many more commands like ENV to set environment variables and EXPOSE to let the Docker image communicate over the specified port with the host operating system as it executes.

Now, to continue learning, you could create your own Docker repository following the Getting Started instructions from Docker and upload the Docker image you just created there.  You can also browse the public repositories to see the many images other people that people have created.

Everything you need to know about outsourcing technology developmentAccess a special Introduction Package with everything you want to know about outsourcing your technology development. How should you evaluate a partner? What components of your solution that are suitable to be handed off to a partner? These answers and more below.

Introduction Package

Source: zymr

Zymr blogger

0 comments

Leave a Reply

© 2019, Zymr, Inc. All Rights Reserved.| LEGAL DISCLAIMER | PRIVACY POLICY | COOKIE POLICY