Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 希望TiDB的Docker官方镜像禁用CGO
In the current Makefile, there are numerous instances of CGO_ENABLED=1
, which causes the official Docker image to throw an error when running on Debian-based Linux systems. The error message is runtime/cgo: pthread_create failed: Operation not permitted
, and it requires additional high privileges to run.
Detailed analysis can be found here: runtime/cgo: pthread_create failed: Operation not permitted · Issue #467 · docker-library/golang · GitHub.
A simple solution is to set CGO_ENABLED=0
, which I tried and it compiled successfully.
Background: Preparing to use Docker to start only one tidb-server in the dev environment for daily self-testing by developers, and found an error when starting in the Ubuntu environment.
PS: Theoretically, if k8s is running on Ubuntu, tidb on k8s should also report an error (not yet tested).
Well, after testing, this error has been fixed in Docker version 20 and above, and the corresponding Ubuntu version is 22.04. That is, after Ubuntu 22.04, directly installing the latest Docker, even if the CGO-enabled image is used, will not report an error.
PS: The tricky part is that Docker version 24 completely deprecated the AUFS
file system. If you used AUFS
, you must change the storage-driver
after upgrading the Docker version, which will cause the old containers to not start and you will have to rebuild the containers 
I have never understood what advantages there are to installing a database in Docker.
Here is the background: TiDB syntax is somewhat different from MySQL 5.7, and it’s for developers’ self-testing. There’s no need to set up a complete TiDB cluster.
Self-testing with a single PD, one TiDB, and one TiKV is sufficient. If you can run MySQL, you can run TiDB. I just use a virtual machine on my own computer to play around.
It’s too complicated for development, not as convenient as using Docker.
Online testing will maintain multiple development branches, and the TiDB environments for different development branches cannot be the same.
Starting three processes is not as good as directly letting TiDB write to the local disk. For development, a single docker run
command or a docker-compose
file is sufficient.
docker run -dt -p 4000:4000 --restart unless-stopped --name tidb-v7.1.1-4000 -v /data/tidb-4000:/data/tidb pingcap/tidb:v7.1.1 --path /data/tidb
PS: By default, tidb-server uses local storage.

This is really impressive, but it should be a benefit after storage based on S3. Looking forward to TiKV on S3 being available for local TiDB clusters, so that one set is enough for the test cluster.
Databases are not typically installed using Docker in a production environment, right?
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.