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
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

Mounting a Local Volume

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

Scenarios

There are four types of local volumes:

  • hostPath: mounts a file directory of the host where the container is located to the specified mount point of the container. For example, if the container needs to access /etc/hosts, you can use hostPath volume to map /etc/hosts.
  • emptyDir: applies to temporary data storage, disaster recovery, and runtime data sharing. It will be deleted upon deletion or transfer of workload pods. The lifecycle is the same as that of the container pod. When the pod is deleted, the emptyDir volume is deleted and its data is lost.
  • ConfigMap: After you mount a ConfigMap to a container, you can read the ConfigMap data from the mount path of the container.
  • Secret: After you mount a secret to a container, you can read the secret data from the mount path of the container.

HostPath

HostPath is a path for mounting a file or directory from a host's file system into a container. Such a volume is usually used to store containerized application logs that need to be stored permanently or containerized applications that need to access internal data structure of the Docker engine on the host.

  1. Set the basic container information by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet. After setting the basic container information, click Data Storage. On the Local Volumes tab page, click .

    Figure 1 Container storage configuration

  2. Set parameters for adding a local volume, as listed in Table 1.

    Table 1 HostPath parameters

    Parameter

    Description

    Volume Type

    Select hostPath.

    hostPath

    Path on the host, for example, /etc/hosts.

    Mount Path

    Container path to which the data volume will be mounted.

    NOTICE:
    • The container path cannot be a system directory, such as / or /var/run. Otherwise, the container may not function normally. Select an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup. Otherwise, the files will be replaced, and the container cannot start normally. As a result, the application may not be created.
    • If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged.

    Subpath

    A subpath is used to mount a local volume so that the same data volume is used in a single pod. If this parameter is left blank, the root path is used.

    Permissions

    • Read-only: You can only read the data in the mounted volume.
    • Read-write: You can modify the volume mounted to the path. Newly written data will not be migrated if the container is migrated, which may cause data loss.

  3. You can add multiple settings. Click OK to complete the configuration.

emptyDir

emptyDir applies to temporary data storage, disaster recovery, and runtime data sharing. It will be deleted upon deletion or transfer of workload pods.

  1. Set the basic container information by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet. After setting the basic container information, click Data Storage. On the Local Volumes tab page, click .

    Figure 2 Container storage configuration

  2. Set parameters for adding a local volume, as listed in Table 2.

    Table 2 emptyDir parameters

    Parameter

    Description

    Volume Type

    Select emptyDir.

    Medium

    • Default: Data is stored in disks. This approach is used when there is a large amount of data, with low requirements on reading and writing efficiency.
    • Memory: You can select this option to improve the running speed, but the storage capacity is subject to the memory size. This mode applies to a small amount of data with high requirements on reading and writing efficiency.

    Mount Path

    Container path to which the data volume will be mounted.

    NOTICE:
    • The container path cannot be a system directory, such as / or /var/run. Otherwise, the container may not function normally. Select an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup. Otherwise, the files will be replaced, and the container cannot start normally. As a result, the application may not be created.
    • If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged.

    Subpath

    A subpath is used to mount a local volume so that the same data volume is used in a single pod. If this parameter is left blank, the root path is used.

    Permissions

    • Read-only: You can only read the data in the mounted volume.
    • Read-write: You can modify the volume mounted to the path. Newly written data will not be migrated if the container is migrated, which may cause data loss.

  3. You can add multiple settings. Click OK to complete the configuration.

ConfigMap

ConfigMap is used to process workload configuration parameters. Before that, you need to create ConfigMaps. For details, see ConfigMaps.

  1. Set the basic container information by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet. After setting the basic container information, click Data Storage. On the Local Volumes tab page, click .

    Figure 3 Container storage configuration

  2. Set parameters for adding a local volume, as listed in Table 3.

    Table 3 ConfigMap parameters

    Parameter

    Description

    Storage Type

    Select ConfigMap.

    ConfigMap

    Select the desired ConfigMap name.
    NOTE:

    A ConfigMap must be created in advance. For details, see ConfigMaps.

    Mount Path

    Container path to which the data volume will be mounted.

    NOTICE:
    • The container path cannot be a system directory, such as / or /var/run. Otherwise, the container may not function normally. Select an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup. Otherwise, the files will be replaced, and the container cannot start normally. As a result, the application may not be created.
    • If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged.

    Subpath

    A subpath is used to mount a local volume so that the same data volume is used in a single pod. If this parameter is left blank, the root path is used.

    Permissions

    Only Read-only is supported. You can only read the file system in the container path.

  3. You can add multiple settings. Click OK to complete the configuration.

Secret

Mount the data in the secret to the specified container. The content of the secret is user-defined. Before that, you need to create a secret. For details, see Secrets.

  1. Set the basic container information by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet. After setting the basic container information, click Data Storage. On the Local Volumes tab page, click .

    Figure 4 Container storage configuration

  2. Set parameters for adding a local volume, as listed in Table 4.

    Table 4 Secret parameters

    Parameter

    Description

    Volume Type

    Select Secret.

    Secrets

    Select the desired secret name.
    NOTE:

    A secret must be created in advance. For details, see Secrets.

    Mount Path

    Container path to which the data volume will be mounted.

    NOTICE:
    • The container path cannot be a system directory, such as / or /var/run. Otherwise, the container may not function normally. Select an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup. Otherwise, the files will be replaced, and the container cannot start normally. As a result, the application may not be created.
    • If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged.

    Subpath

    A subpath is used to mount a local volume so that the same data volume is used in a single pod. If this parameter is left blank, the root path is used.

    Permissions

    Only Read-only is supported. You can only read the file system in the container path.

  3. You can add multiple settings. Click OK to complete the configuration.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback