Hope the official Docker image of TiDB disables CGO

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 希望TiDB的Docker官方镜像禁用CGO

| username: dba-kit

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.

| username: dba-kit | Original post link

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

| username: TiDBer_oHSwKxOH | Original post link

Expert. Professional.

| username: Kongdom | Original post link

:+1: :+1: :+1:

| username: dba-kit | Original post link

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

| username: 像风一样的男子 | Original post link

I have never understood what advantages there are to installing a database in Docker.

| username: dba-kit | Original post link

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.

| username: zhanggame1 | Original post link

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.

| username: ShawnYan | Original post link

It’s too complicated for development, not as convenient as using Docker.

| username: dba-kit | Original post link

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

| username: ShawnYan | Original post link

At this point, insert ad

| username: 像风一样的男子 | Original post link

This is pretty good.

| username: dba-kit | Original post link

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.

| username: Fly-bird | Original post link

Databases are not typically installed using Docker in a production environment, right?

| username: dba-kit | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.