Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Uploading an Image

Updated on 2024-06-18 GMT+08:00

Introduction

SWR provides easy, secure, and reliable management for container images throughout their lifecycles, facilitating the deployment of containerized applications. This section uses the 2048 application as an example to show how to install the container engine, build an image, and use the container engine to upload the image to SWR.

NOTE:
  • There are two ways to upload an image to SWR: using a container engine client or the SWR console. This section describes how to use a container engine client to upload an image. For details about how to upload an image on the console, see Uploading an Image Through SWR Console.
  • Currently, there are no SWR APIs available for uploading images.

The following diagram shows the process of uploading an image to SWR.

Figure 1 Process

Prerequisites

You already have a Huawei Cloud account.

If you do not have a Huawei Cloud account, perform the following steps to create one:

  1. Visit Huawei Cloud and click Sign Up.
  2. On the page displayed, sign up for an account. After you have successfully signed up, the system automatically redirects you to your personal information page.

Step 1: Install the Container Engine

Prepare an ECS, on which Docker 1.11.2 or later is installed.

  1. Create a Linux ECS with an EIP. For details, see Purchasing and Logging In to a Linux ECS.

    For demonstration, you do not need to select high-specification ECS and public IP address. For example, select the ECS with 1 vCPUs | 2 GB, the public IP bandwidth of 1 Mbit/s, and the operating system with CentOS 7.5.

    NOTE:
    • You can also install the container engine on other machines.
    • If you use a CentOS, you are advised to use CentOS 7, CentOS 7.2, CentOS 7.3, CentOS 7.4, CentOS 7.5 or CentOS 7.6 to avoid exceptions during the installation.

  2. After the ECS is created, return to the ECS list and click Remote Login to log in to the ECS as user root.
  3. Run the following commands to quickly install the container engine:

    curl -fsSL get.docker.com -o get-docker.sh
    sh get-docker.sh
    sudo systemctl daemon-reload
    sudo systemctl restart docker

Step 2: Build an Image

  1. Run the following command on the ECS where Docker is installed to download the source code of the 2048 application:

    git clone https://gitee.com/jorgensen/2048.git

    NOTE:

    If the message "git: command not found" is displayed, the Git tool is not installed. In this case, run the yum install git command to install it first.

  2. After the download is successful, access the 2048 directory.

    cd 2048

  3. Modify the Dockerfile file.

    vim Dockerfile

    FROM nginx
    COPY . /usr/share/nginx/html
    
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]
    • FROM: specifies nginx as the base image.
    • COPY: copies the source code of the 2048 application to the directory /usr/share/nginx/html in the container.
    • EXPOSE: exposes port 80 of the container.
    • CMD: specifies the default command to run the container.

    Press Esc and enter :wq to save the settings and exit.

  4. Run the docker build command to build an image.

    docker build -t 2048 .

    In the preceding command:

    • -t indicates to label the image, that is, to name the image. In this example, the image name is 2048.
    • . indicates the context path. All contents in this path are packed and sent to the container engine to build an image.

  5. Run the following command to view the 2048 image that has been successfully built. The image tag is latest by default.

    docker images

    # docker images
    REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
    2048         latest    8d421c503ed0   About a minute ago   134MB
    nginx        latest    dd34e67e3371   6 days ago           133MB

    You can also see a nginx image, which is pulled from the image repository and used as the base image of the 2048 image.

  6. (Optional) Run the container image.

    After the image is successfully built, you can run the docker run command to run the container image.

    docker run -p 8080:80 2048

    The docker run command starts a container. In the preceding command, -p indicates that port 8080 of the VM is mapped to port 80 of the container. When you access https://EIP of the ECS:8080, the container is accessed. The 2048 application page is displayed.

Step 3: Create an Organization

An organization is used to isolate images and grant access permissions, namely, read, edit, and manage, to different users under an account.

  1. Log in to the SWR console.
  2. In the navigation pane on the left, choose Organization Management. On the displayed page, click Create Organization in the upper right corner.
  3. Enter the organization name and click OK.

    Figure 2 Creating an organization

Step 4: Connect to SWR

  1. Log in to the SWR console.
  2. In the navigation pane on the left, choose Dashboard and click Generate Login Command in the upper right corner. On the displayed page, click to copy the login command.

    Figure 3 Generating a login command
    NOTE:

    The validity period of the generated login command is 6 hours. To obtain a long-term valid login command, see Obtaining a Long-Term Valid Login Command.

  3. Run the login command on the VM where the container engine is installed.

    The message Login Succeeded will be displayed upon a successful login.

Step 5: Upload the Image

  1. Run the following command to label the 2048 image on the VM where the container engine is installed:

    docker tag[Image name 1:tag 1] [Image repository address]/[Organization name]/[Image name 2:tag 2]

    In the preceding command:

    • [Image name 1:tag 1]: name and tag of the image to be uploaded.
    • [Image repository address]: The domain name at the end of the login command in Step 4: Connect to SWR is the image repository address, which can be obtained on the SWR console.
    • [Organization name]: name of the organization created in Step 3: Create an Organization.
    • [Image name 2:tag 2]: desired image name and tag.

    Example:

    docker tag 2048:latest swr.ap-southeast-1.myhuaweicloud.com/cloud-develop/2048:v1

  2. Push the image to the image repository.

    docker push [Image repository address]/[Organization name]/[Image name 2:tag 2]

    Example:

    docker push swr.ap-southeast-1.myhuaweicloud.com/cloud-develop/2048:v1

    The following information will be returned upon a successful push:

    The push refers to repository [swr.ap-southeast-1.myhuaweicloud.com/cloud-develop/2048]
    fbce26647e70: Pushed 
    fb04ab8effa8: Pushed 
    8f736d52032f: Pushed 
    009f1d338b57: Pushed 
    678bbd796838: Pushed 
    d1279c519351: Pushed 
    f68ef921efae: Pushed 
    v1: digest: sha256:0cdfc7910db531bfa7726de4c19ec556bc9190aad9bd3de93787e8bce3385f8d size: 1780

    To view the pushed image, go to the SWR console and refresh the My Images page.

  3. Use the pushed image to deploy a workload on CCE.

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback