Help Center > > Best Practices> Containerizing Enterprise Applications> Step 2: Preparing the Application Runtime Environment

Step 2: Preparing the Application Runtime Environment

Updated at: Nov 11, 2019 GMT+08:00

After application analysis, you have gained the understanding of the OS and runtime environment required by the application. You need to prepare these environments.

  • Installing Docker: During application containerization, you need to build a Docker image. To do so, you have to prepare a PC and install Docker on it.
  • Obtaining the base image version: Determine the base image based on the OS on which the application runs. In this example, the application runs on CentOS 7.1 and the base image can be obtained from Docker Hub.
  • Obtaining the runtime environment: Obtain the runtime environment of the application and the MongoDB database with which the application interconnects.

Installing Docker

Docker can nearly be installed on all OSs. You can select the Docker version to be installed as required. For more information, see https://docs.docker.com/engine/installation/.

HUAWEI CLOUD SWR uses Docker 1.11.2 or later to upload images.

  1. Log in as the root user to the device on which Docker is about to be installed.
  2. Run the following commands to quickly install Docker on the device running Linux:

    curl -fsSL get.docker.com -o get-docker.sh

    sh get-docker.sh

  3. Run the following command to query the Docker version:

    docker version
    Client:
    Version: 17.12.0-ce
    API Version:1.35
    ...

    Version indicates the version number.

Obtaining the Base Image Version

Determine the base image based on the OS on which the application runs. In this example, the application runs on CentOS 7.1 and the base image can be obtained from Docker Hub.

Search for the image version based on the OS on which the application runs.

  1. Log in to https://hub.docker.com/.
  2. Search for CentOS. The image corresponding to CentOS 7.1 is centos7.1.1503. You need to use this image name when compiling the Dockerfile.

    Figure 1 Obtaining the CentOS version

Obtaining the Runtime Environment

In this example, the web application of the Tomcat type is used. This application requires the runtime environment of Tomcat 7.0, and Tomcat requires JDK 1.8. In addition, the application must interconnect with the MongoDB database in advance.

Download the environment required by the application.

  1. Download Tomcat, JDK, and MongoDB installation packages of the specific versions.

    1. Download JDK 1.8 from http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html.
    2. Download Tomcat 7.0 from https://tomcat.apache.org/download-70.cgi.
    3. Download MongoDB 3.2 from https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.9.tgz.

  2. Log in as the root user to the device running Docker.
  3. Run the following commands to create the directory where the application is to be stored: For example, set the directory to testapp.

    mkdir testapp

    cd testapp

  4. Use XShell to save the downloaded dependency files to the testapp directory.
  5. Run the following commands to decompress the dependency files:

    tar -zxf apache-tomcat-7.0.82.tar.gz

    tar -zxf jdk-8u151-linux-x64.tar.gz

    tar -zxf mongodb-linux-x86_64-rhel70-3.2.9.tgz

  6. Save the enterprise application (for example, apptest.war) in the webapps/apptest directory of the Tomcat runtime environment.

    In this example, no application packages are provided. Therefore, this step cannot be performed.

    mkdir -p apache-tomcat-7.0.82/webapps/apptest

    cp apptest.war apache-tomcat-7.0.82/webapps/apptest

    cd apache-tomcat-7.0.82/webapps/apptest

    ./../../../jdk1.8.0_151/bin/jar -xf apptest.war

    rm -rf awcp.war

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel