Deploy Docker on Simple Application Server

更新时间:
复制 MD 格式

Deploy a Docker environment on a Simple Application Server using the Docker application image from Alibaba Cloud, and start an Nginx container.

Note

Procedure

Step 1: Deploy Docker

Note

If you already have a Simple Application Server, deploy Docker by selecting the Docker application image when you reset the system. Resetting the system erases all data on the system disk. Back up your data before you proceed. Reset a Simple Application Server.

  1. Go to the Servers page in the Simple Application Server console.

  2. In the middle of the page, click Create Server.

  3. On the Simple Application Server page, configure the following parameters.

    Note

    Available images and plans vary by region and instance type. The buy page in the console takes precedence.

    Configuration Item

    Example

    Description

    Servers

    • Instance family: General-purpose

    • Select an instance family: Options include general-purpose, Multi-IP, International, and Large-capacity. Instance families.

    • Select a plan: Click image to view more plans. Each plan bundles vCPUs, memory, a system disk, and a data transfer plan. Instance specifications.

      Important

      To create a Windows instance, select a plan that provides a system disk larger than 40 GiB.

    Image

    • Application Image: Docker

    • Image Version: Docker 26.1.3

    On the Application Images tab, select the Docker image.

    image

    Region

    Singapore

    Select a region close to your target users to reduce network latency. You cannot change the region after the instance is created.

    Important

    Instances in regions outside the Chinese mainland, such as China (Hong Kong) and Singapore, use international bandwidth, which may cause high latency from within the Chinese mainland. Select the region closest to your target users. Regions and network connectivity.

    Purchase Settings

    • Quantity: 1

    • Duration: 1 Month

    • Quantity: the number of instances to purchase. Default: 1.

    • Duration: the subscription duration. Default: 1 month.

      Important

      Instances hosting web services in the Chinese mainland require an ICP filing with a subscription duration of 3 months or longer (including renewals). Domain name filing.

      • Monthly subscription: 1 month, 3 months, or 6 months.

      • Yearly subscription: 1 year, 2 years, or 3 years.

      Enable Auto-renewal is enabled by default to prevent disruptions from expired subscriptions. Auto-renewal.

      • For monthly subscriptions, the renewal period is one month.

      • For yearly subscriptions, the renewal period is one year.

  4. Click Buy Now and complete the payment.

    When the server status changes from Pending to Running, Docker deployment is complete.

    image

Step 2: Use Docker

  1. Go to the Servers page in the Simple Application Server console.

  2. On the Servers page, find the Simple Application Server created from the Docker image and click its instance ID.

  3. Click the Application Details tab. In the Docker Usage section, click Log on to the simple application server..

    The application details also show the Docker version, status, and installation path.

    image

  4. In the Remote Connection dialog box, click Log on Now.

  5. Use Docker on the server.

    The following steps use an Nginx container as an example.

    1. Pull the Nginx image.

      sudo docker pull nginx
    2. View local images.

      sudo docker images

      The following output indicates that the Nginx image is available locally.

      image

    3. Create and run an Nginx container in the background, binding it to port 80 of the server.

      sudo docker run --name <container_alias> --network host -d <image_name>(REPOSITORY)

      In this example, the image name is nginx and the container alias is nginx-test01. Sample command:

      sudo docker run --name nginx-test01 --network host -d nginx
      Note

      Use the image name returned by the docker images command.

    4. View running containers.

      sudo docker ps

      Sample output:

      image

    5. In a browser, access the public IP address of the Simple Application Server.

      If the following page appears, the Nginx container is deployed. If you cannot access Nginx, verify that port 80 is enabled in the firewall settings. Set up a firewall.

      nginx