Docker 安装 Polardb-X 数据库 容器 教程
好习惯,附上之前的 7 篇
CentOS 7.9 环境安装 PolarDB-X 数据库: https://developer.aliyun.com/article/1704678
银河麒麟V10操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1704731
欧拉 openEuler 20.03 操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1704866
PolarDB-X 集中式三节点高可用集群部署 & Java 场景 CRUD 应用: https://developer.aliyun.com/article/1705878
Ubuntu 18.04.6 操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1706016
ARM 欧拉 openEuler 20.03 操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1706028
Debian 10 操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1706119
本篇换个玩法,Docker 容器版一键拉起,快速启动
0. env
- docker env
qc@ubuntu ~ $ docker version
Client: Docker Engine - Community
Version: 29.1.3
API version: 1.52
Go version: go1.25.5
Git commit: f52814d
Built: Fri Dec 12 14:49:48 2025
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 29.1.3
API version: 1.52 (minimum version 1.44)
Go version: go1.25.5
Git commit: fbf3ed2
Built: Fri Dec 12 14:49:48 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.2.1
GitCommit: dea7da592f5d1d2b7755e3a161be07f43fad8f75
runc:
Version: 1.3.4
GitCommit: v1.3.4-0-gd6d73eb8
docker-init:
Version: 0.19.0
GitCommit: de40ad0
qc@ubuntu ~ $
1. pull images
qc@ubuntu ~ $ docker pull docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825
v2.4.2_5.4.19-20250825: Pulling from polardbx/polardb-x
c363cefcac6b: Pull complete
22983ff8e73f: Pull complete
2d473b07cdd5: Pull complete
4f4fb700ef54: Pull complete
a662ee9e8b84: Pull complete
c366476ee604: Pull complete
ca7f651d1b1e: Pull complete
bf9976dcf52d: Pull complete
6b91da6c5783: Pull complete
Digest: sha256:b67f638616cf250aa5bb133a7dba060c574c2b88ee4ff3936b1f8ede208edab7
Status: Downloaded newer image for docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825
docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825
qc@ubuntu ~ $
qc@ubuntu ~ $ docker tag docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825 polardb-x:v2.4.2_5.4.19
qc@ubuntu ~ $
qc@ubuntu ~ $ docker rmi docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825
Untagged: docker.1ms.run/polardbx/polardb-x:v2.4.2_5.4.19-20250825
qc@ubuntu ~ $
qc@ubuntu ~ $ docker images|grep polardb
polardb-x:v2.4.2_5.4.19 b67f638616cf 5.96GB 1.53GB
qc@ubuntu ~ $
2. run polardb-x container
qc@ubuntu ~/bin $ vim run_polardbx.sh
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ cat run_polardbx.sh
#!/bin/sh
docker run -dit \
--name polardb-x_1 \
-p 34886:4886 \
-m 4GB \
polardb-x:v2.4.2_5.4.19
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ sh run_polardbx.sh
8f846d6eb4ffa47ccc55800423e105a9b902664c46bf5af769db8531a93281b5
qc@ubuntu ~/bin $
3. check polardb-x container
qc@ubuntu ~/bin $ vim check_polardbx.sh
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ cat check_polardbx.sh
#!/bin/sh
docker ps|grep "polardb-x_1"
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ sh check_polardbx.sh
8f846d6eb4ff polardb-x:v2.4.2_5.4.19 "/home/polarx/entryp…" 24 seconds ago Up 24 seconds 0.0.0.0:34886->4886/tcp, [::]:34886->4886/tcp polardb-x_1
qc@ubuntu ~/bin $
4. exec polardb-x container
qc@ubuntu ~/bin $ vim exec_polardbx.sh
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ cat exec_polardbx.sh
#!/bin/sh
docker exec -it polardb-x_1 bash
qc@ubuntu ~/bin $
qc@ubuntu ~/bin $ sh exec_polardbx.sh
[polarx@8f846d6eb4ff ~]$
5. client login polardb-x
[polarx@8f846d6eb4ff ~]$ vim login_polardbx.sh
[polarx@8f846d6eb4ff ~]$
[polarx@8f846d6eb4ff ~]$ cat login_polardbx.sh
#!/bin/sh
~/polardbx/build/run/polardbx-engine/u01/mysql/bin/mysql -h127.0.0.1 -P4886 -uroot
[polarx@8f846d6eb4ff ~]$
[polarx@8f846d6eb4ff ~]$ sh login_polardbx.sh
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 136
Server version: 8.0.32-X-Cluster-8.4.19-20250825 Source distribution
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+----------------------------------+
| version() |
+----------------------------------+
| 8.0.32-X-Cluster-8.4.19-20250825 |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2026-01-14 17:09:16 |
+---------------------+
1 row in set (0.00 sec)
mysql>