The Docker practice tutorial based on IBM Bluemix

Source: Internet
Author: User

Lin Bingwen Evankaka original works. Reprint please specify the source Http://blog.csdn.net/evankaka

Summary: This article begins with a brief introduction to Docker and IBM Bluemix, and then explains how to configure the operating environment for the Docker containers and mirrors of IBM Bluemix via the Ubuntu14.04 OS. It demonstrates the local operation of mirroring push into Bluemix and creates a run container output and some Docker-related command operations on Bluemix.

Operating system:

Ubuntu14.04

I. Preparatory work required

1. Sign up for a Bluemix account

2, some basic knowledge of Docker, such as what is a mirror, what is a container?

3, the relevant Linux command, it is best to set their own Ubuntu14.04 can network, you can save a lot of copy files work, a apt-get can!

second, what is Docker?

What is a docker image?

A Docker image is a read-only template. For example, an image can contain a full Ubuntu operating system environment with only the Apache or other applications needed by the user installed. Mirroring can be used to create Docker containers. Docker provides a very simple mechanism for creating mirrors or updating existing ones, and users can even download a well-done image directly from someone else and use it directly.

(I note: The image here corresponds to the container image in Bluemix)

What is a docker container?

The Docker container is an open-source application container engine that allows developers to package their applications and dependencies into a portable container, and then publish them to any popular Linux machine or virtualize them. Containers are completely sandbox -aware, with no interface (like IPhone apps) between them. There is little performance overhead and can be easily run in the machine and data center. Most importantly, they are not dependent on any language, framework including system.

(I note: The container here can correspond to the container in Bluemix)

What can it do?

1, the automation of Web applications packaging and publishing;

2, automated testing and continuous integration, release;

3, in the service-oriented environment to deploy and adjust the database or other background applications;

4. Build your own PAAs environment by compiling from scratch or by expanding your existing OpenShift or cloud foundry platform.

About Bluemix

IBM Bluemix is an open standard cloud platform for building, running, and managing applications. With Bluemix, developers can focus on building a superior user experience with flexible computing options, the choice of DevOps tools, and a powerful set of IBM and third-party APIs and services.

III. Preparation of the environment

1. Download and install the CF command line, which is also the cloud Foundry CLI V6.11.3 or later

Download URL https://github.com/cloudfoundry/cli/releases


This is the file after the download


The Deb format is easy to install and uses commands directly

Dpkg-icf-cli-installer_6.14.0_x86-64.deb

Install it all the way! Once this is done, you can use Bluemix to develop and deploy your own apps! As below (note:JavaWebProject2 is a Web app created on my own Bluemix , and the first time you connect to Bluemix needs to download the project, unzip it, execute the following command)


This article is because of the dcoker operation, so you need to do the following steps!

2. Install DockerV1.6, 1.7, 1.8 or 1.8.1

After you install this locally, Bluemix can identify the Docker commands on your machine.

Install Docker 1.6, 1.7, 1.8, or 1.8.1. To obtain operating system-specific information. You can download Docker V1.8.1 using a URL for one of the following popular operating systems.

OS X 64-bit: https://get.docker.com/builds/Darwin/x86_64/docker-1.8.1

OS X 32-bit: https://get.docker.com/builds/Darwin/i386/docker-1.8.1

Linux 64-bit: https://get.docker.com/builds/Linux/x86_64/docker-1.8.1

Linux 32-bit: https://get.docker.com/builds/Linux/i386/docker-1.8.1

Windows 64-bit: Https://get.docker.com/builds/Windows/x86_64/docker-1.8.1.exe

Windows 32-bit: Https://get.docker.com/builds/Windows/i386/docker-1.8.1.exe

(Note: the 1.8.1 Replace 1.6.1 or 1.7.1 can download the corresponding version), here i download the Linux 64-bit, to see what is downloaded?


This is a binary execution file that you want to install? Two lines of command!

First, give the binary file a right, using the following command,

Chmod +xdocker-1.8.1

Then perform the installation

./docker-1.8.1

The process is as follows (note that the CD enters the same folder as the docker-1.8.1 binary execution file)


3. Install the IBM Containers Cloud Foundry Plugin

Install the ibm®containers Cloud Foundry plugin to run the native Docker CLI command to manage the container. This means that after installing this, you can establish a connecting channel between the local Docker and the Byluemix.

64-bit input:

CF Install-plugin Https://static-ice.ng.Bluemix.net/ibm-containers-linux_x64

32-bit input:

CF Install-plugin Https://static-ice.ng.Bluemix.net/ibm-containers-linux_x86

Below is


You can also verify the plug-in installation by running the following command and checking the list of installed Cloud Foundry plugins.

CF Plugins

As follows


Get ready to start your Docker journey on Bluemix!

Iv. Bluemix uses Docker-related commands

1. View your current image on Bluemix

Use the command:

CF IC images;

The first time you run, you may see the following error


Follow the prompts and enter the CF IC init. To run the command just now, the results are as follows:


Of course, you can also use the Bluemix website to view


The image of the above two image is corresponding (Bluemix is called a container image, which is actually a docker image)

2. View the currently running container

Using commands

CF IC PS;


Of course, you can also use the Bluemix website to view

Note: The container that runs here is the one I created at the Bluemix official dot click, and no container was running at the beginning.

3. Enter the inside of the container that is running

CF IC Attach Lincontain


Unfortunately, the entry failed.

This indicates that there is no entry into the container by viewing the official documentation. It clearly indicates that this method is not supported to enter the container, only by configuring SSH to log in. However, the official website does not recommend that you enter the container via SSH.

Please see here:

Login to Container

Here is some information on the official website:

There are not many cases where you must access container content. If you need access, you can log on to the container as SSH by performing the following steps.

IMPORTANT: When you push an image to your organization's dedicated Bluemix repository, the vulnerability Advisor automatically scans those images. The vulnerability advisor marks the image that contains the SSH key as a policy violation. You can still continue to use images marked as violated, but keep in mind that the ability to log on to a container is considered a vulnerability.

· Step 1. Create SSH Key pair

· Step 2. will be SSH add key to Container

· Step 3. through SSH log in to container

More commands please visit the official website, or direct CF IC (I note: Docker commands have, it also basically has, but some are not able to run)

v. Bluemix submits a custom Docker image

The most critical step is coming!

First look at what I have in the local mirror it!


Now I want the local Ubuntu ouruser/ubuntu this image push to the Bluemix Personal Center, note that this image_id is 1f879014f4d2.

First, mark the image with your private namespace in the IBM Containers registry.

1. Use your private namespace in the IBM Containers registry to mark the image.

Template:

Docker tag Image_name Registry.ng.bluemix.net/namespace/image_name:image_tag

Parameters:

Namespace: Namespace (Bluemix automatically sets it up for you)

Image_name: Mirror Name

Image_tag: Mirror Label

Where: namespace can use CF IC namespace get to view

Instance:


The image name is called an option. If the name is not specified, the image is marked as latest.

2. Push this image to the IBM Containers registry

Template:

Docker Push Registry.ng.bluemix.net/namespace/image_name:image_tag

Parameters:

Namespace: Namespace (Bluemix automatically sets it up for you)

Image_name: Mirror Name

Image_tag: Mirror Label

Where: namespace can use CF IC namespace get to view

Instance:


if the above information appears Push success, can also go to personal Bluemix Center to see, open the dashboard - start the container. You can see your own Docker container, where 1f879014f4d2 is the name of the container and is related to push - time settings.


The following error may occur with this step:

Workaround:

Re-use CF IC login login and then push

3. You can create a container from this image in the Bluemix directory, or you can use the following command to create a container

Template:

CF IC Run--name container_nameregistry.ng.bluemix.net/namespace/image_name:image_tag

Parameters:

Namespace: Namespace (Bluemix automatically sets it up for you)

Container_name the name of the container you want to start

Image_name: Mirror Name

Image_tag: Mirror Label

Instance:


Failed to start the container, do not know is not because it does not support? It is not possible to start from the command line either with the author's own container or with a container on the Bluemix center. So this article describes how to start from the Web page.

VI. Bluemix runs its own container

1, click on the Dashboard, start container, select your own uploaded image, click to enter. The contents are as follows:


Problems that may occur:

When a custom container is successfully published to Bluemix, the following error may occur when creating the container, meaning there is a vulnerability in the container that cannot be directly created to run


To view the cause of the problem:

Click Viewthe Vulnerabilityreport for this image to view the vulnerability of the submitted mirror, such as the author's following: This image here shows 7 vulnerabilities and lists the 7 vulnerabilities.


It is very detailed, not only lists the errors, but also lists the workarounds, as follows:


At this point, you can re-modify your container outside and then push again, and the vulnerabilities will disappear. Of course, if you do not want to fix these problems and want to run some images directly, then please look below.

Workaround:

Click manageyour org ' s policiesto customize your strategy and enter the following: The action on the left for the vulnerability, and the right for the image on the personal Bluemix Center is handled in a vulnerable manner


This can be mirrored when the configuration is a vulnerability, block or warn, the default is block, then you cannot run the container, by setting the Warn, the following display:

This allows you to return to the page where the container was created. The following page appears:


Description You can run the container from your own image!

2. Run your own container

After completing the above steps, go to the created page. Enter the container name, whether to bind the public IP, the port number (the public IP is bound to the other computer through SSH to access the container). Clicking on the Advanced option will show the apps that have been created on your personal Bluemix center, and selecting the corresponding application can be bound to the container.

The larger picture is as follows:


Last step, click Create! Bluemix automatically configures your container and binds your application as required. Final run interface results view:

You can see the private ip/public IP that the container runs, as well as the ports used, the applications/services that are bound, and the running state of the current container.


At this point, you have successfully created your own container from your custom image!

Vii. Summary:

Bluemix is a powerful platform through which you can save a lot of time on development and operational dimensions. But to upload your own image and run your own container on Bluemix, the process is tedious. The author first builds the environment on the Windows platform, but has not been able to connect to the personal Bluemix Image Center via the CF IC Login. Then in the Ubuntu14.04 upload image and create containers also encountered a lot of problems, but these problems in the official website of the manual can find a solution. Recommend a good crossing Web manual.

Reference article:

docker--from getting started to practicing

IBM Bluemix Documentation

The Docker practice tutorial based on IBM Bluemix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.