# Docker Environment
## Introduction
OpenHarmony provides the following two types of Docker environments for you to quickly get the development environment ready:
- Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution
- HPM-based Docker environment: applicable when using the HarmonyOS Package Manager \(HPM\) to build a distribution
**Table 1** Docker image
Docker Environment
|
System Type
|
Operating Platform
|
Docker Image Repository
|
Tag
|
Standalone Docker environment
|
Mini and small systems
|
Ubuntu or Windows
|
swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker
|
1.0.0
|
Standard system
|
Ubuntu
|
swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker
|
1.0.0
|
HPM-based Docker environment
|
Mini and small systems
|
Ubuntu or Windows
|
swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker
|
0.0.3
|
## Preparations
Before using the Docker environment, perform the following operations:
1. Install Docker. For details, see [Install Docker Engine](https://docs.docker.com/engine/install/).
2. Obtain the OpenHarmony source code. For details, see [Source Code Acquisition](sourcecode-acquire.md).
>![](../public_sys-resources/icon-note.gif) **NOTE**
>You do not need to obtain the source code for the HPM-based Docker environment.
## Standalone Docker Environment
The Docker image of OpenHarmony is hosted on HUAWEI CLOUD SWR. Using the Docker image will help simplify environment configurations needed for the building. The following describes the detailed procedure.
### Setting Up the Docker Environment for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
1. Obtain the Docker image.
```
docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
```
2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
Run the following command in Ubuntu:
```
docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
```
Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
```
docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
```
### Building for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
The following uses the Hi3516 platform as an example to describe the build procedure.
Set the build path to the current path.
```
hb set
```
**Figure 1** Setting page
![](figure/setting-page.png "setting-page")
>![](../public_sys-resources/icon-note.gif) **NOTE**
>The mapping between the development board and the building GUI:
>
>- Hi3861: wifiiot\_hispark\_pegasus@hisilicon
>- Hi3516: ipcamera\_hispark\_taurus@hisilicon
>- Hi3518: ipcamera\_hispark\_aries@hisilicon
1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**.
2. Start building.
```
hb build -f
```
3. View the build result.
The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)
1. Obtain the Docker image.
```
docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
```
2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
```
docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
```
### Building for Standard-System Devices \(reference memory ≥ 128 MB\)
Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\).
```
./build.sh --product-name {product_name} --ccache
```
**product\_name** indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
>![](../public_sys-resources/icon-note.gif) **NOTE**
>You can exit Docker by simply running the **exit** command.
## HPM-based Docker Environment
**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment:
### Setting Up the Docker Environment
1. Initialize the installation template by running the following command in any of the working directories:
```
hpm init -t @ohos/docker_dist
```
2. Modify the **publishAs** field.
The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
### Obtaining and Building Source Code
Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.
- **Automatically Installing Docker \(Ubuntu\)**
Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container.
**Method 1:**
Add a parameter to specify the solution. For example:
```
hpm run docker solution={product}
```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
**Method 2:**
Set an environment variable to specify the solution, and then run the build command.
1. Select the desired solution.
```
export solution={product}
```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
2. Obtain and build the source code.
```
hpm run docker
```
This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
```
...
ohos ipcamera_hispark_taurus build success!
@ohos/hispark_taurus: distribution building completed.
```
- **Manually Installing Docker \(Non-Ubuntu\)**
Perform the following operations to install Docker:
```
# Pull the image.
docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3# Compile the Docker image in the Linux environment.
hpm run distWithDocker solution={product}
# When using Windows, make sure to configure the Git Bash.
hpm config set shellPath "Git Bash path"
hpm run distWithDocker solution={product}
```