Mindmajix

Management of Complex Docker Containers

Docker containers are highly used in production environments. Due to the nature of this environment, the containers used in this case are very complex. One needs to know how to manage these. This will be explored in this chapter.

The Docker Machine Beta

This tool was recently introduced, and it can help you to move from nothing to a very complex Docker container. It can be used for creation of Docker containers on your machine, in cloud environments, in data centers, and then it is used for configuration of the Docker client so as to communicate to these. It is used as follows:

Screenshot_22

On execution of the above command, everything will be set up. This will download the Machine and then install it on your computer. Notice the use of the “ -d” flag, which will run the process in the background. The command will run in a verbose manner, and you will observe the following output as it runs:

Screenshot_2

This shows that it tells or informs you of how it is progressing. Once the above command completes its execution, just run the following command:

Screenshot_3

There will be no observed output from the above command. Next, just run the following command so as to test whether or not the installation ran successfully:

Screenshot_4

What the above command does is that it checks for the presence of the “busybox” image in your local system. If it is not available, it will download it from the Docker Hub. The image will then be executed, and you will observe some text on the output. The command will run in a verbose manner, and in my case, I get the following output:

Screenshot_5

As shown in the above figure, the command has finally printed the “hello world” message. The image was not found locally, so this is why it has been pulled from the Docker Hub.

How to run a Dockerized App

Installation of the Docker is very easy. Once you have installed it, you need to run the dockerized application. With the Docker, a Registry which contains public applications is maintained which are made available as public images. In this section, we will explore how to use the “JSDetox” JavaScript deobfuscation tool in your Docker.

There are a number of packages which need to be installed alongside this package. The problem is that most of these packages might end up conflicting with the ones you have already installed. However, due to the distribution property provided by the Docker, this problem is solved.

The image for this can be run by executing the following command:

Screenshot_6

Once the above command has been executed, open your browser, and then enter the following URL:

http://localhost:3000

In my system, I get the following output from the previous command:

docker containers

In case you are using either Mac OS X or the Windows operating system, the steps can be a bit tricky. However, with the assistance of the boot2docker tool, this will become easy. You just have to connect the IP address of the virtual machine being set up by the Docker. As shown in the above figure, the image which we have specified, that is
“remnux/jsdetox,” was not found in the local system, so it was downloaded from the Docker Registry. After running the JSDetox, it will begin to listen from the port number 3000. However, we will be unable to access the port from our container, due to the fact that it is running from a container. We have to redirect to the port so that we get the
following output:

Screenshot_8

The above will be the output on the browser once we execute the URL which we previously gave.

Building process

Suppose that we want to build the Docker image for the application. To do this, we canstart with the core image of the core OS, and then run it in the Docker. Necessary toolscan then be installed, and then perform the necessary configurations. Consider the command given below:

Screenshot_9

What the command does is that it will instruct the Docker to use the Ubuntu’s 14.04 public license as the base image of the image we are going to create. Consider the next instructions given below:

Screenshot_10

What the commands do is that they will instruct for the OS to be upgraded, and for some packages to be installed. These are the packages which the JSDetox needs so as to be able to run. Note that the command “apt-get” should be run while having the administrative privileges. Consider the next command given below:

Screenshot_11

What the above command does is that it adds a group and a user named “nonroot” to our image. This means that we will be able to run or launch the JSDetox without having the administrative privileges. Consider the next commands given below:

Screenshot_12

The commands shown above are responsible for the downloading of the JSDetox from the GitHub repository. This will be done as a “nonroot” user.

The next commands are given below:

Screenshot_14

What they do is that they will install the JSDetox into the system.

Now that we have accomplished the task of downloading and installation, we need to establish a way how it will be launched or started. Consider the commands given below:

Screenshot_15

When the above commands are executed, you will have specified how the JSDetox application will be started by the Docker once the container is launched. You will then be done.


0 Responses on Management of Complex Docker Containers"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.