This topic explains how to deploy a single-node OceanBase database in a Docker container.
Notice
The operations described in this topic are intended for learning or testing purposes only. Do not apply them to production environments.
Prerequisites
Before you perform the operations in this topic, make sure that the following conditions are met:
You have installed and started Docker. For more information, see Docker documentation.
Note
On x86-based Mac machines, only Docker V4.9.0 and earlier are supported for deploying OceanBase Database. You can click here to download Docker.
Your machine meets the software and hardware requirements. For more information, see Software and hardware requirements.
Deploy OceanBase Database
(Optional) Step 1: Pull the OceanBase Database image
Run the following commands to pull the required image for OceanBase Database.
Search for OceanBase Database images
[admin@test001 ~]$ sudo docker search oceanbasePull the latest OceanBase Database image
[admin@test001 ~]$ sudo docker pull oceanbase/oceanbase-ceNote
If the Docker image pull fails, you can also pull the image from the quay.io or ghcr.io repositories. Just replace
oceanbase/oceanbase-cein the pull command withquay.io/oceanbase/oceanbase-ceorghcr.io/oceanbase/oceanbase-ce, for example, executesudo docker pull quay.io/oceanbase/oceanbase-ceto pull the image from quay.io.If you change the repository address in the command of this step, you also need to change the repository address in the command of Step 2. The two commands must use the same repository.
The above commands default to pulling the latest version. You can choose a version from dockerhub, quay.io, or ghcr.io based on your needs.
Step 2: Start an OceanBase Database instance
Run the following commands to start an OceanBase Database instance.
[admin@test001 ~]$ sudo docker run -p 2881:2881 -p 2886:2886 -v $PWD/ob:/root/ob -v $PWD/obd/cluster:/root/.obd/cluster --name obstandalone -e MODE=NORMAL -e OB_TENANT_PASSWORD=***** -d oceanbase/oceanbase-ce
[admin@test001 ~]$ sudo docker run -p 2881:2881 -p 2886:2886 -v $PWD/ob:/root/ob -v $PWD/obd/cluster:/root/.obd/cluster --name obstandalone -e MODE=MINI -e OB_TENANT_PASSWORD=***** -d oceanbase/oceanbase-ce
fast-start mode, if you configure environment variables for tenants and resources, only the OB_TENANT_PASSWORD and OB_SYS_PASSWORD variables take effect. The default and only user tenant name created is test.
shell dmin@test001 ~]$ sudo docker run -p 2881:2881 -p 2886:2886 -v $PWD/ob:/root/ob -v $PWD/obd/cluster:/root/.obd/cluster --name obstandalone -e MODE=SLIM -d oceanbase/oceanbase-ce
The options in the example are described as follows:
-pmaps the container's ports to the host's ports. In the example, it maps container ports2881and2886to host ports2881and2886.-vshares files or directories between the container and the host, enabling data persistence or configuration sharing. By default, the system deploys OceanBase Database in the/root/obdirectory of the container and saves its configuration in/root/.obd/cluster. You can use this option to persist data on the host.You can also use the
-voption to mount an SQL script for execution. Here's an example. You need to replace{init_sql_folder_path}with the actual path to the initialization SQL file.[admin@test001 ~]$ sudo docker run -p 2881:2881 -p 2886:2886 -v {init_sql_folder_path}:/root/boot/init.d --name obstandalone -e MODE=SLIM -d oceanbase/oceanbase-ce--namesets the Docker container name. For example, the example creates a Docker container namedobstandalone.-esets environment variables. In the example,MODEsets the startup mode for OceanBase Database, andOB_TENANT_PASSWORDsets the password for the root@test user in OceanBase Database. For more information about the environment variables, see Supported environment variables below.
Note
The enable_rich_error_msg parameter is enabled by default when Docker starts. If an error occurs, you can use the trace command to obtain detailed error information.
Starting an instance takes about 2 to 5 minutes. Run the following command. If the output is boot success!, the instance is started.
[admin@test001 ~]$ sudo docker logs obstandalone | tail -1
boot success!
Step 3: Connect to the OceanBase Database instance
The oceanbase-ce image includes obd (OceanBase Deployer, an OceanBase installation and deployment tool) and OBClient (OceanBase command-line client). You can enter the container and use obd commands or the OBClient client to manage and connect to the instance. Alternatively, you can use the OBClient or MySQL client on the host to connect to the OceanBase Database instance.
Connect to the instance after entering the container
Enter the Docker container.
[admin@test001 ~]$ sudo docker exec -it obstandalone bashView the cluster details.
# View the list of clusters. obd cluster list # View the details of the obcluster cluster. obd cluster display obclusterConnect to the cluster.
obclient -h127.0.0.1 -uroot@sys -A -Doceanbase -P2881 -p
Connect to the instance using the host's client
You can use the OBClient or MySQL client on the host to connect to the OceanBase Database instance. Here's an example:
[admin@test001 ~]$ obclient -uroot@sys -h127.0.0.1 -P2881 -p
Note
If you do not configure the password through environment variables when starting the OceanBase Database instance, the password of the user created in the instance is empty by default.
After a successful connection, the terminal displays the following content:
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221711319
Server version: OceanBase_CE 4.3.5.3 (r103010012025090210-8b80b225c2dcba7dd0c83f3d5a24e3c1ffc03f24) (Built Sep 2 2025 10:25:24)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [(none)]>
Step 4: Access the obshell Dashboard
You can access the obshell Dashboard, a web-based management interface provided by obshell, by visiting port 2886 on the host.
Supported environment variables
Variable |
Default value |
Value description |
Description |
|---|---|---|---|
| MODE | MINI |
NoteIf |
Specifies the cluster startup mode. |
| EXIT_WHILE_ERROR | true |
|
Specifies whether to exit the container when OceanBase Database cannot be started. |
| OB_CLUSTER_NAME | obcluster | N/A | Specifies the name of the OceanBase cluster. |
| OB_TENANT_NAME | test | The value can be up to 63 bytes in length and can contain only uppercase and lowercase letters, digits, and underscores. It cannot be a keyword of OceanBase Database. | Specifies the name of the MySQL tenant in the OceanBase cluster. If this parameter is not specified, a tenant named test is created by default.
NoteIf |
| OB_MEMORY_LIMIT | 6G | [6G, +∞) | Specifies the total memory available to the OceanBase cluster. The effect is the same as the memory_limit parameter in the other two schemes. |
| OB_DATAFILE_SIZE | 5G | [5G, +∞) | Specifies the size of the data files in the OceanBase cluster. The effect is the same as the datafile_size parameter in the other two schemes. |
| OB_LOG_DISK_SIZE | 5G | [5G, +∞) | Specifies the size of the redo log disk in the OceanBase cluster. The effect is the same as the log_disk_size parameter in the other two schemes. |
| OB_SYS_PASSWORD | Empty string | The value must be a string. | Specifies the password of the sys tenant administrator user (root@sys) in the OceanBase cluster. |
| OB_TENANT_PASSWORD | Empty string | The value must be a string. | Specifies the password of the administrator user of the tenant corresponding to the value of the OB_TENANT_NAME parameter. If the OB_TENANT_NAME parameter is not specified, the password of the root@test user is used by default. |
| OB_SYSTEM_MEMORY | 1G | [1G, +∞) | Specifies the memory capacity reserved for the tenant with the tenant ID of 500 in the OceanBase cluster. The effect is the same as the system_memory parameter in the other two schemes. |
| OB_TENANT_MIN_CPU | N/A | N/A | Specifies the minimum CPU specification of the tenant corresponding to the value of the OB_TENANT_NAME parameter in the OceanBase cluster. If this parameter is not specified, the tenant will occupy all remaining resources in the OceanBase cluster. The effect is the same as the MIN_CPU parameter in the CREATE RESOURCE UNIT statement. For more information, see CREATE RESOURCE UNIT. |
| OB_TENANT_MEMORY_SIZE | N/A | N/A | Specifies the memory specification of the tenant corresponding to the value of the OB_TENANT_NAME parameter in the OceanBase cluster. If this parameter is not specified, the tenant will occupy all remaining resources in the OceanBase cluster. The effect is the same as the MEMORY_SIZE parameter in the CREATE RESOURCE UNIT statement. For more information, see CREATE RESOURCE UNIT. |
| OB_TENANT_LOG_DISK_SIZE | N/A | N/A | Specifies the size of the log disk space of the tenant corresponding to the value of the OB_TENANT_NAME parameter in the OceanBase cluster. If this parameter is not specified, the tenant will occupy all remaining resources in the OceanBase cluster. The effect is the same as the LOG_DISK_SIZE parameter in the CREATE RESOURCE UNIT statement. For more information, see CREATE RESOURCE UNIT. |
| OB_CONFIGSERVER_ADDRESS | N/A | N/A | Specifies the address of obconfigserver. Example: http://10.10.10.1:8080. |
