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.
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:
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:
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:
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:
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:
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.
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:
Once the above command has been executed, open your browser, and then enter the following URL:
In my system, I get the following output from the previous command:
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
The above will be the output on the browser once we execute the URL which we previously gave.
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:
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:
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:
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:
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:
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:
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.
|Docker Kubernetes Training|
|OpenShift Administration Training|
Get Updates on Tech posts, Interview & Certification questions and training schedules