×
Community Blog Creating an Alibaba Cloud Container Service Application with Docker Swarm

Creating an Alibaba Cloud Container Service Application with Docker Swarm

In this tutorial, we'll show you how to create a Docker container cluster using Alibaba Cloud's Container Service.

In this tutorial, we'll show you how to create an Alibaba Cloud Container Service application environment running on Docker containers managed by a Swarm cluster built up on Alibaba Cloud Elastic Compute Service (ECS) instances that we have already set up in a previous tutorial.

In the past, developers had to install, run, and monitor their development and production system environments on racks of physical machines in gigantic server rooms. Nowadays, new containerization technology with virtual management tools, such as Docker Swarm and Kubernetes, allows developers to manage and monitor their production and development environments running collections of Docker application containers directly through Alibaba Cloud's Container Service, using its console web-based user interface.

What Is Alibaba Cloud's Container Service?

Alibaba Cloud's Container Service is a scalable, high-performance, container management product that allows you to orchestrate and manage containerized application lifecycles with either Docker Swarm or Kubernetes. Container Service comes with an automatic built in Server Load Balancer that is installed Pay-As-You-Go.

Alibaba Cloud's Container Service offers multiple application release methods, including continuous integration, and also supports a microservices architecture. By offering a simplified user interface console setup for a container cluster, which integrates with Alibaba Cloud's virtualization, storage, network, and security services, Alibaba Cloud's Container Service is the perfect cloud environment for running, managing, and monitoring containerized application environments.

What Is Docker Swarm?

Docker is an open source, virtualization management tool that allows you to develop, deploy, manage, and monitor applications and collections of applications that run within containers. This process is known as containerization. Docker Swarm is a clustering, scheduling, and orchestration tool for such systems and environments that are running on multiple and scalable Docker containers.

A Docker container is launched by running a Docker image which is an executable package that includes everything needed for running an entire application: code, runtime, libraries, environment variables, and configuration files. A container is a runtime instance of a Docker image.

You can run multiple containers at the same time on the same instance, or on a Docker Swarm cluster of instances. The running containers are managed by Docker instead of an operating system's hypervisor; and Docker, unlike a hypervisor, provides redundancy and failover if one or more of the cluster nodes experience any problems.

Docker is lightweight and efficient and can manage complex systems built up of multiple application images. You can build Docker containers locally, or deploy them to the cloud, and you can run them anywhere; scaling up and down wherever necessary.

Docker is easy to set up, install, and run on a single Alibaba Cloud ECS instance. A large-scale containerized environment running industry level applications and systems needs a reliable and scalable orchestration and monitoring system. Alibaba Cloud's Container Service provides system administrators and DevOps teams with the vast clustered architectures they need to manage extensive containerized environments.

Why Do We Need a Cluster?

Before we can install a suite of running Docker containers with Alibaba Cloud's Container Service Docker Swarm option, we need to have an Alibaba Cloud Container Service Docker Swarm cluster ready and available for implementing our containerized systems.

In a previous tutorial, we showed you how easy it is to set up a Docker Swarm cluster for running a containerized environment with Alibaba Cloud's Container Service. We will use the same running cluster in this tutorial to build out an application environment. We will build an environment with a web server built from an image, and a web application built from an orchestration template, both coming as part of the Alibaba Cloud's Container Service product offerings.

Prerequisites

You will need an Alibaba Cloud account. If you don't already have one, head over to the Free Trial page to access $300 worth of Alibaba Cloud products in the Alibaba Cloud New User Free Trial.

Let's get started.

Check the Alibaba Cloud Container Service Cluster Is Running

Let's first make sure our Docker Swarm cluster is running. Head over to the Container Service console page in your Alibaba Cloud account.

1

You will arrive at the Container Service console page.

Make sure the Container Service – Swarm option is selected before clicking the Cluster option on the left side menu.

If all's well, you should see a Running cluster in a Healthy state.

2

Create a Docker Swarm Container Service Application

Go to the Applications menu option and click Create Application.

3

In the Basic Options, add a name for the application, a version number (default is 1.0), select the cluster you wish to use for the application (we only have one running cluster, so this is defaulted), and select your release strategy:

Standard release deletes any earlier versions of your application before deploying the new version. This is sufficient for our tutorial. Blue-green release is an active-standby option for applications which need to continue to run without interruption when updating.

Creating a Container by Pulling a Docker Image

Add a description of your application and select the Pull Docker Image option.

4

Now click Create with Image.

5

You will move forward to the Configuration options. In General Settings, click Select Image.

6

Select the nginx option and click OK.

7

The latest Docker image version is pulled from remote Docker repositories by default.

You can now click Create on the right-hand side.

8

You will see a confirmation that the application is being created.

9

Now you will see your nginx application in both the Applications and Services menus.

10

11

In the Applications menu, click the nginx running application.

12

Click Update.

13

Now, we can configure the networking.

Add the Port Mapping details for HTTP/HTTPS 80 and 443, and the Container Port.

14

Now click Update.

15

You will see the application creating and then eventually settle into a Running state.

Click the Applications menu option.

16

Click through to the application details.

17

In this view, you will see a number of tabs. The Services tab shows the state of the application.

Click the Containers tab. In this view, you will see all the VPC network port settings, the container IP, and the node IP. You also have the option to monitor the container.

18

Click the name link.

19

You will see a number of graphs, including the container's CPU, memory, IO, and process utilizations over time.

Now click the Logs tab.

20

Here you will see the logs for the container. Now click Events.

21

This option will show you a list of events on the container. Now click the Routes tab.

22

Here you will see the container's endpoint. Go ahead and click the link.

23

You should see confirmation that you have set up the nginx container correctly and it is running.

24

Creating a Container with an Orchestration Template

Now let's integrate WordPress with nginx on the same cluster.

This time, we will use an orchestration template. Go back to the Container Service console and click Applications. Check you're on the correct cluster (we still have just the one) and click Create Application.

25

The procedures are exactly the same as before but instead of clicking Create with Image, we will click Create with Orchestration Template. We can leave the Docker Image option unselected in this case.

26

For those familiar with the Docker ecosphere, you can run your Docker compose files here. We will click Use Existing Orchestration Template.

27

Let's select WordPress.

28

As you can see, the console populates with the relevant Docker compose commands and configuration.

29

We need to edit one of the configurations now.

30

This configuration change should mean that any requests to aliyun port 80 from the test domain URL should route to WordPress.

31

Now click Create and Destroy.

32

You will see your application running. Click the Applications menu and you will see WordPress creating.

33

Once the application is created, you will see it in the running state. Click through to the application.

34

As before, you will see a number of tabs. WordPress has two tabs as it needs a database and a web application in order to run. Click the Containers tab.

35

The Containers tab shows details of all the different running Docker containers the application requires.

36

Logs and Events tabs show details as we saw before. If you click Routes, you get the WordPress endpoint URL which you will need to set up your application.

Go ahead and click the endpoint.

37

You can now set up your WordPress site running on the nginx webserver we set up previously.

38

Summary

First, we explained how we had already built an Alibaba Cloud Container Service Docker Swarm cluster in preparation for building out a containerized environment and we checked it was running correctly.

Next, we explained about the Alibaba Cloud Container Service product and how you can use it with both Swarm and Kubernetes containerized environments. We also explained how these products need clusters to run on and how Alibaba Cloud will auto set up clusters built from Elastic Compute Services (ECS) and even include a Server Load Balancer as part of the auto set up.

We then showed you how to build an Alibaba Cloud Docker Swarm Containerize Service of applications starting by pulling a nginx webserver Docker image down remotely from Docker. We then used an Orchestration Template to pull down a WordPress image which allows for much more developer flexibility.

Thanks for reading and don't forget to check out the other products and services Alibaba Cloud offers.
https://www.alibabacloud.com/contact-sales

0 0 0
Share on

Alibaba Clouder

1,407 posts | 218 followers

You may also like

Comments