Log on to the Container Service console.
Click Applications in the left-side navigation pane.
Click Create Application in the upper-right corner.
Complete the basic information for the application you are about to create:
- Name: Enter the name of the application. It can be 1–64 characters long and contain numbers, English letters, and hyphens (-), but cannot start with a hyphen (-).
- Version: Enter the version of the application. By default, 1.0 is entered.
- Cluster: Select the cluster on which the application will be deployed.
- Update: The update method of the application. Select Standard Release or Blue-Green Release. For more information, see Overview of release policies.
- Description: Enter the information of the application. This field is optional. The entered description cannot exceed 1024 characters and will be displayed on the Application List page.
- Pull Docker Image: With this check box selected, Container Service pulls the latest Docker image from the repository to deploy the application, even when the image tag does not change.
To improve efficiency, Container Service caches the image. When deploying an application, Container Service uses the cached image instead of pulling the image from the repository if the image tag is the same as that of the local cache. Therefore, if you modify your codes and image but do not modify the image tag for the convenience of upper business, Container Service will use the old image cached locally to deploy the application. With this check box selected, Container Service ignores the cached image and re-pulls the image from the repository when deploying the application to make sure the latest image and codes are always used.
Click Create with Image or Create with Orchestration Template.
Click Create with Image. Complete the following configurations as per your needs:
In the General section:
Set the Image Name and Image Version.
You can select an image provided by Container Service or enter your image address in the format of
domainname/namespace/imagename:tag. To select an image, click Select image, select the image, and then click OK.
By default, Container Service uses the latest version of the image. To use another version of the image, click Select image version, select the version, and then click OK.
Set the number of containers (Scale).
Select the Network Mode of the application.
Currently, Container Service supports two network modes: Default and host. The Default mode is the bridge network mode. The host network mode allows containers to use the network stacks of Elastic Compute Service (ECS) instances. For more information, see Docker container networking.
Set the Restart field.
The Always check box is selected by default. With the check box selected, the containers will be restarted regardless of the exit status code. Docker daemon restarts the containers unlimitedly. Whatever the container status is, the container tries to be restarted when daemon is started.
With the check box deselected, the restart policy becomes no, indicating containers will not be restarted automatically on exit.
In the Container section:
Set the startup command (Command and Entrypoint) of the container.
If configured, the image default configurations will be overwritten.
Command is used to specify the startup command of the container main process. For more information, see Command.
Entrypoint is used to specify the container startup process and parameter. Used together with command, the cmd contents can be passed to Entrypoint as parameters. For more information, see Entrypoint.
Set the resource limits (CPU Limit and Memory Limit) of the container.
Set the resource limit for the CPU and memory to be used by the container. For more information, see Restrict container resources.
Set the Capabilities.
For how to add or drop Linux related privileges for the container, see Capabilities.
Set the Container Config.
In the Network section:
Set the Port Mapping. Specify the port mapping for the host and the container, and select TCP or UDP as the protocol.
The port mapping is used for the routing between container and host, and is the precondition of Web Routing and Load Balancer. The container provides external services by means of the configured port mapping.
Set the Web Routing. The cluster automatically creates the acsrouting application, including the routing service, and provides the simple routing function. A routing service instance is deployed on each node. In a node, the
acsrouting_routing_indexcontainer implements the routing forward in the cluster to route the HTTP or HTTPS service. For more information, see Simple routing - supports HTTP and HTTPS.
Note: When exposing the HTTP/HTTPS services, you can use the overlay network or Virtual Private Cloud (VPC) to directly access the container port, without configuring the specific host port.
Set the Load Balancer. Configure the port mapping before configuring the mapping of
$scheme://$[slb_name|slb_id]:$slb_front_port. For how to use the Server Load Balancer label, see lb.
When configuring this parameter, control the routing access path on your own, including the routing mapping of Server Load Balancer front end port > backend host port > container port.
Set the Data Volume.
- Create a data volume. Enter the host path or data volume name, the container path, and select RW or RO as the data volume permission. For more information, see volume.
- Configure the volumes_from field. Enter the name and permission parameter of another service or container, such as
service_name:ro. If no access permission is specified, RW is the default permission. For more information, see volumes_from. After the configuration, you can successfully authorize this container to use the data volumes of another service or container.
Set the Environment variables.
Formats such as array, dictionary, and boolean are supported. For more information, see Environment variables.
Set the container Labels.
For the extension labels supported by Container Service, see Label description.
In the Deploy section:
Set whether or not to enable Smooth Upgrade for containers.
For more information, see rolling_updates.
Set the Across Multiple Zones settings for containers.
- Select Ensure to deploy containers in two zones. The container creation fails if less than two zones are in the current cluster, or the containers cannot be deployed in two zones because of limited machine resources.
- Select Try best to try to deploy containers in two zones. The container can still be created even if this condition is not met.
If you do not configure this field, Container Service will deploy the containers in a single zone by default.
For more information, see High availability scheduling.
Set whether or not to enable the container Auto Scaling.
For more information, see Container auto scaling.
Click Create at the right of the page after completing the settings.
Click Create with Orchestration Template.
Click Use Existing Orchestration Template or write a new template by yourself.
Note: The contents of the orchestration template comply with the Docker Compose format.
Click Select next to the template after clicking Use Existing Orchestration Template.
Edit the orchestration template as per your needs by:
- Making modifications in the template directly.
- Clicking Edit to modify the service.
- Clicking Delete to delete the service.
- Clicking Add Service to add another service to this orchestration template.
Click Create and Deploy after completing the settings.