Containers

You can run Docker containers on Bluemix by using the Containers compute option. Containers are a great option when you require resource isolation and the portability of your applications and application runtime environments. IBM Containers are based upon Docker container technology. With containers, you have the ability to move dockerized or containerized application environments quickly from development to test, pre-production or production. Additionally, with containers, you can also build highly available applications by using what is called container groups, which are clustered containers, having the same application environment or built from same container image. You can also enable auto recovery while creating a container group; by doing so, new container instances are automatically created if and when any of the already existing containers in the container group go down. A container group can be created even with a single instance of container.

Note

To get a detailed understanding of how IBM Containers leverage Docker technology, you can refer to https://ibm.biz/Bdrd67 .

If you are already a Docker user, you can bring your Docker images from Docker Hub to a private registry hosted by IBM and you will be able to use the same images to create containers on Bluemix that are same as the Docker containers you have worked on.

Note

To know how to go about copying your images from Docker Hub to the IBM registry, you can refer to https://ibm.biz/BdrdUX .

Creating an IBM Container with an existing image

In this section, we will learn how to create an IBM Container instance from IBM-provided images. To get the Liberty server in a container, we will build a container from an existing image.

Before you begin

There are a few utilities that are required to be installed locally on your machine, so that you can work with IBM Containers on Bluemix. Make sure you have the following supported versions of utilities installed:

  • Docker version 1.6, 1.7, 1.8, 1.8.1, 1.9.0, 1.9.1, or 1.10.0
  • Cloud Foundry CLI version 6.14.0 to 6.16.0
  • IBM Containers Cloud Foundry plug in

Installing Docker

Based on the operating system you are using, you will need to follow the instructions from the links shown here:

The screenshots shown in this section will correspond to Docker installation steps on OS X:

  1. Click on the link in the preceding table, corresponding to the OS you are using; here we will use the OS X related link to explain the steps. This will download  DockerToolbox-1.10.0.pkg to your local system.
  2. Double-click on the  .pkg file to start the installation of the Docker Toolbox.
  3. Follow the steps in the wizard to continue with the installation. The components installed as part of the Docker Toolbox installation are shown in the following screenshot:

    Installing Docker

  4. Once the installation is complete, you can start working with the Docker terminal. This completes the installation of Docker:

    Installing Docker

Installing Cloud Foundry CLI

The installation of Cloud Foundry CLI has been explained in an earlier chapter; if you are reading this chapter after carrying out the exercises and demos from earlier chapters then you should already have cf cli on your system. You can find the version of the cf cli by opening the terminal window or command prompt, based on your OS, and typing the following command:

cf -v

The results of running this command would give you the information on the version of CF CLI that you are using, such as what is shown here:

Installing Cloud Foundry CLI

Installing the IBM Containers Cloud Foundry plugin

You will need to run the  cf command from the following table, based on the operating system you are working on:

OS X

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-mac

Windows 64-bit

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-windows_x64.exe

Windows 32-bit

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-windows_x86.exe

Linux 64-bit

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x64

Linux 32-bit

cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-linux_x86

Tip

Install Cloud Foundry command line (cf cli) plugin before you follow the steps in this section to install the IBM Containers plug-in for cf cli.

The installation steps are as follows:

  1. Open your command line or terminal window, based on your operating system, and type the command from the preceding table:
    cf install-plugin 
            https://static-ice.ng.bluemix.net/ibm-containers-mac
    

    The following screenshot shows the output generated:

    Installing the IBM Containers Cloud Foundry plugin

  2. The IBM Containers plugin for Cloud Foundry command line is installed. Type the following command to verify the installation was successful:
    cf plugins
    

    The results of execution are displayed as shown in the following screenshot. You will see the IBM Containers plugin listed as one of the  cf plugins installed:

    Installing the IBM Containers Cloud Foundry plugin

Creating a container using the Bluemix dashboard

We will now learn to create a single container using the Bluemix dashboard.

Note

You can also create scalable container groups on Bluemix; for detailed steps on how to create them, you can refer to https://ibm.biz/BdrxyN .

The following are the steps to create a single container:

  1. Log in to your Bluemix dashboard.
  2. Click Compute from the Dashboard Categories and select Containers:

    Creating a container using the Bluemix dashboard

  3. Click Get started now!, shown in the preceding screenshot.
  4. This is will display the container images that are available in the private Bluemix registry; we will choose to create a container with WebSphere Liberty installed, so we will choose the ibmliberty image, shown in the following screenshot:

    Creating a container using the Bluemix dashboard

  5. Enter the details in the following screen to create your container from the ibmliberty image. Enter the container name and choose a size for your container, which defines the memory and storage capacity of the container you are creating. You can also choose to bind a public IP to the container you are creating.
  6. Click CREATE at the bottom of the screen to start the container creation:

    Creating a container using the Bluemix dashboard

  7. Once the container is created, you will see the Overview page for the container that you just created, as shown in the following screenshot:

    Creating a container using the Bluemix dashboard

  8. If you have not yet requested a public IP, you can do so from the Overview page, by clicking the Request and bind a new public IP option, as shown here:

    Creating a container using the Bluemix dashboard

    Once the public IP is bound to your container, you can see it as shown in the screenshot here:

    Creating a container using the Bluemix dashboard

    You can also bind Bluemix services to the container you have created. The Connections tab will show the services that are bound to your container:

    Creating a container using the Bluemix dashboard

You can now see the container you have created in the dashboard view for your Containers compute option, as shown here:

Creating a container using the Bluemix dashboard

Working with the CF plugin for IBM Containers

Before you can start working with Cloud Foundry IBM Containers plugin, you will need to run the following command from your terminal window or from the command prompt, based on the operating system you are using:

cf ic init

The results of execution of the command is show here:

Working with the CF plugin for IBM Containers

To get the details on the container that you just created, so as to work with it using the command line plugin, you will need to execute the following command:

cf ic ps

This command will list all the containers you have created within your Bluemix organization.

The result of execution of this command is shown in the following screenshot; you will see the single container that we just created is listed along with other details about the container such as its ID, name, and so on:

Working with the CF plugin for IBM Containers

Note

For a detailed reference on the cf cli IBM Containers plugin commands, you can refer to https://ibm.biz/BdrxMD .

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.157.197