- What's new
- Function Overview
- Service Overview
- Getting Started
-
User Guide
- Introduction
- Permissions Management
- Basics of the Container Engine
-
Image Management
- Uploading an Image Through a Container Engine Client (Recommended)
- Obtaining a Long-Term Valid Login Command
- Uploading an Image Through SWR Console
- Pulling an Image
- Setting Image Attributes
- Sharing a Private Image
- Adding a Trigger
- Adding an Image Retention Policy
- Configuring Automatic Image Synchronization Between Regions
- Image Center
- Organization Management
- User Permissions
- Auditing
- Change History
- Best Practices
-
API Reference
- Before You Start
- Calling APIs
- API Overview
-
API
- Organization Management
- Managing Image Repositories
- Image Tag Management
- Shared Account Management
- API Version
- Organization Permission Management
- Image Permission Management
- Image Synchronization Management
- Trigger Management
- Image Retention Policy Management
- Temporary Login Command
- Quota Management
- Other
- Example Applications
- Appendixes
- SDK Reference
-
FAQs
- General FAQs
- Login Issues
- Synchronizing Images
- Pushing an Image
- Pulling an Image
-
Troubleshooting
- Why Does the Login Command Fail to Be Executed?
- Why Does an Image Fail to Be Pushed Through a Container Engine Client?
- Why Does an Image Fail to Be Uploaded Through SWR Console?
- Why Does the docker pull Command Fail to Be Executed?
- What Should I Do If Images Cannot Be Downloaded from Private Networks?
- What Do I Do If an Error Occurs When I Call an API?
-
Other FAQs
- Why Does a CCE Workload Cannot Pull an Image from SWR and a Message "Not Logged In" Is Displayed?
- How Many Tenants Can I Share an SWR Private Image With?
- Why Is an Image Pushed Using a Container Engine Client to SWR Different in Size From One Uploaded Through the SWR Console?
- Can I Pull Images on the SWR Console to a Local PC?
- Videos
- Glossary
-
More Documents
- User Guide
- API Reference
- User Guide (Paris Regions)
- API Reference (Paris Regions)
- User Guide (Kuala Lumpur Region)
- API Reference (Kuala Lumpur Region)
-
User Guide (Ankara Region)
- Service Overview
- Overview
- Permissions Management
- Basics of Docker
-
Image Management
- Pushing an Image Through a Container Engine Client
- Obtaining a Long-Term Valid Docker Login Command
- Obtaining a Long-Term Valid containerd Pull/Push Command
- Uploading an Image Through the SWR Console
- Pulling an Image
- Setting Image Attributes
- Sharing Private Images
- Adding a Trigger
- Adding an Image Retention Policy
- Organization Management
- User Permissions
- FAQs
-
API Reference (Ankara Region)
- Before You Start
- API Overview
- Calling APIs
- API
- Appendixes
- Permissions and Supported Actions
- General Reference
Copied.
Basics of the Container Engine
The container engine is an open source engine which allows you to create a lightweight, portable, and self-sufficient container for any application.
Preparations Before Installation
Before installing the container engine, you should understand the basic knowledge of the container engine. For details, see Docker Documentation.
Selecting an Edition of Container Engine
The container engine is compatible with almost all operating systems. Select an edition that best suits your needs. If you are not sure which edition to use, see https://docs.docker.com/engine/install/.
- It is advised to install container engine 1.11.2 or later because earlier versions do not support image push to SWR.
- If the container engine client is in a private network, bind an elastic IP address (EIP) to the client. This EIP will allow the client to download container engine installation packages from the website.
Installing the Container Engine
You can select either of the following installation procedures based on your OS.
- Linux OS
Run the following commands to quickly install the latest edition. To install a specific edition, see Docker Engine installation overview.
curl -fsSL get.docker.com -o get-docker.sh sh get-docker.sh sudo systemctl daemon-reload sudo systemctl restart docker
- EulerOS
The procedure of installing the container engine in EulerOS is as follows:
- Log in to ECS where you want to install the container engine.
- Configure a yum repository.
If you have not configured a yum repository on the host, configure one. For details, see How Can I Use an Automated Tool to Configure a Huawei Cloud Image Source (x86_64 and Arm)? If you have configured one, skip this step.
- Install and run the container engine.
- Run the following command to obtain the docker-engine package from the yum repository.
yum search docker-engine
- Run the yum install -y command to install the docker-engine package obtained in the previous step. The following is an example in the x86 architecture:
yum install docker-engine.x86_64 -y
- Set the container engine to start at system startup.
- Start the container engine.
- Run the following command to obtain the docker-engine package from the yum repository.
- Check the installation result.
If information similar to the following is displayed, the container engine is successfully installed:
Docker version 18.09.0, build 384e3e9
Building a Container Image
This section walks you through the steps of using a Dockerfile to build a container image for a simple web application. Dockerfile is a text file that contains all the instructions a user can call on the command line to build an image. A container image is a stack consisting of multiple layers. Each instruction creates a layer.
When using a browser to access a containerized application built from a Nginx image, you will see the default Nginx welcome page. In this section, you will build a new image based on the Nginx image to change the welcome message to Hello, SWR!
- Log in to the container engine as the root user.
- Run the following commands to create an empty file named Dockerfile:
mkdir mynginx
cd mynginx
touch Dockerfile
- Edit the Dockerfile.
vim Dockerfile
Add the following instructions to the Dockerfile:
FROM nginx RUN echo '<h1>Hello, SWR!</h1>' > /usr/share/nginx/html/index.html
In the preceding instructions:
- FROM: creates a layer from the base image. A valid Dockerfile must start with a FROM instruction. In this example, the Nginx image is used as the base image.
- RUN: executes a command to create a layer. One of its syntax forms is RUN <command>. In this example, the echo command is executed to display Hello, SWR!
Press Esc and enter :wq to save the settings and exit.
- Run docker build [option] <context path> to build an image.
docker build -t nginx:v1 .
- -t nginx:v1: specifies the image name and tag.
- .: indicates the path where the Dockerfile is located. All contents in this path are packed and sent to the container engine to build an image.
- Run the following command to check the created image. The command output shows that the Nginx image has been created with a tag of v1.
docker images
Creating an Image Package
This section describes how to compress a container image into a .tar or .tar.gz package.
- Log in to the container engine as the root user.
- Run the following command to check images:
docker images
Check the name and tag of the image to be compressed.
- Run the following command to compress the image into a package:
docker save [OPTIONS] IMAGE [IMAGE...]
NOTE:
OPTIONS: You can set this to --output or -o, indicating that the image is exported to a file.
The file should be in either .tar or .tar.gz.
When using docker save to create an image package, use {image}:{tag} instead of image id. Otherwise, the package cannot be uploaded on the SWR page.
Example:
$ docker save nginx:latest > nginx.tar $ ls -sh nginx.tar 108M nginx.tar $ docker save php:5-apache > php.tar.gz $ ls -sh php.tar.gz 372M php.tar.gz $ docker save --output nginx.tar nginx $ ls -sh nginx.tar 108M nginx.tar $ docker save -o nginx-all.tar nginx # Packages all Nginx versions. $ docker save -o nginx-latest.tar nginx:latest
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot