[解决方法] GitLab-CE容器启动报错:Unexpected Error: ----------------- ThreadError: can‘t create Thread: Opera

容器启动一直失败,容器内部挂载的目录缺少权限引起的。于是我尝试添加目录 777 权限./gitlab/data也还是不行。还是报相同错误:

# docker-compose up -d
[+] Running 1/1
 ✔ Container gitlab  Started                                                                                                               0.7s 
[root@release-compile debug_gitlab]# docker logs -f gitlab
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=17.10.4-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab editor /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Cleaning stale PIDs & sockets
cat: /var/opt/gitlab/gitlab-rails/VERSION: No such file or directory
Preparing services...
Starting services...
Configuring GitLab...
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
[2025-05-14T23:31:34+00:00] INFO: Started Cinc Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook)
Cinc Client, version 18.3.0
Patents: https://www.chef.io/patents
Infra Phase starting
[2025-05-14T23:31:34+00:00] INFO: *** Cinc Client 18.3.0 ***
[2025-05-14T23:31:34+00:00] INFO: Platform: x86_64-linux
[2025-05-14T23:31:34+00:00] INFO: Cinc-client pid: 28
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/ffi-yajl-2.6.0/lib/ffi_yajl/encoder.rb:42: warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
[2025-05-14T23:31:35+00:00] INFO: Setting the run_list to ["recipe[gitlab]"] from CLI options
[2025-05-14T23:31:35+00:00] INFO: Run List is [recipe[gitlab]]
[2025-05-14T23:31:35+00:00] INFO: Run List expands to [gitlab]
[2025-05-14T23:31:35+00:00] INFO: Starting Cinc Client Run for gitlab666
[2025-05-14T23:31:35+00:00] INFO: Running start handlers
[2025-05-14T23:31:35+00:00] INFO: Start handlers complete.
Resolving cookbooks for run list: ["gitlab"]
[2025-05-14T23:31:35+00:00] INFO: Loading cookbooks [gitlab@0.0.1, package@0.1.0, logrotate@0.1.0, postgresql@0.1.0, redis@0.1.0, monitoring@0.1.0, registry@0.1.0, mattermost@0.1.0, consul@0.1.0, gitaly@0.1.0, praefect@0.1.0, gitlab-kas@0.1.0, gitlab-pages@0.1.0, letsencrypt@0.1.0, nginx@0.1.0, runit@5.1.7, acme@4.1.6, crond@0.1.0]
Synchronizing cookbooks:
  
  ================================================================================
  Error Syncing Cookbooks:
  ================================================================================
  
  Unexpected Error:
  -----------------
  ThreadError: can't create Thread: Operation not permitted
  
  System Info:
  ------------
  chef_version=18.3.0
  platform=ubuntu
  platform_version=22.04
  ruby=ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-linux]
  program_name=/opt/gitlab/embedded/bin/cinc-client
  executable=/opt/gitlab/embedded/bin/cinc-client
  
  
  Running handlers:
[2025-05-14T23:31:35+00:00] ERROR: Running exception handlers
There was an error running gitlab-ctl reconfigure:

can't create Thread: Operation not permitted

  Running handlers complete
[2025-05-14T23:31:35+00:00] ERROR: Exception handlers complete
  Infra Phase failed. 0 resources updated in 01 seconds
[2025-05-14T23:31:36+00:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/cinc-stacktrace.out
[2025-05-14T23:31:36+00:00] FATAL: ---------------------------------------------------------------------------------------
[2025-05-14T23:31:36+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
[2025-05-14T23:31:36+00:00] FATAL: ---------------------------------------------------------------------------------------
[2025-05-14T23:31:36+00:00] FATAL: ThreadError: can't create Thread: Operation not permitted

解决方案

步骤 1:调整Docker容器的权限配置

docker-compose.yml中增加以下配置,授予容器必要的系统权限:

services:
  gitlab:
    # 其他配置保持不变...
    cap_add:
      - SYS_ADMIN          # 允许修改系统参数
      - SYS_RESOURCE       # 允许调整资源限制
    security_opt:
      - seccomp:unconfined  # 禁用Seccomp过滤(可选,根据环境调整)
      - apparmor:unconfined # 禁用AppArmor(可选)
步骤 2:检查宿主机ulimit设置

确保宿主机允许足够的进程数和文件描述符:

# 临时生效(重启失效)
ulimit -n 65535         # 文件描述符
ulimit -u unlimited     # 用户进程数

# 永久生效(编辑/etc/security/limits.conf)
echo "* soft nofile 65535" | sudo tee -a /etc/security/limits.conf
echo "* hard nofile 65535" | sudo tee -a /etc/security/limits.conf
echo "* soft nproc  unlimited" | sudo tee -a /etc/security/limits.conf
echo "* hard nproc  unlimited" | sudo tee -a /etc/security/limits.conf
步骤 3:清理旧数据并重建容器
# 停止并删除容器及关联卷
docker-compose down -v

# 删除旧数据(确认已备份)
sudo rm -rf gitlab/

# 重新创建数据目录并设置宽松权限(仅测试环境)
mkdir -p gitlab/{config,logs,data}
chmod -R 755 gitlab/

# 重新启动容器
docker-compose up -d
docker logs -f gitlab

关键配置解释

配置项 作用
cap_add: SYS_ADMIN 允许容器执行挂载文件系统、修改系统参数等特权操作
security_opt 禁用安全模块(如Seccomp/AppArmor),解决线程创建被拦截的问题
ulimit调整 确保宿主机资源限制不会影响容器内进程创建和文件操作

搞定,问题解决!终于启动成功了

# docker-compose up -d
[+] Running 2/2
 ✔ Network debug_gitlab_default  Created                                                         0.1s 
 ✔ Container gitlab              Started                                                         0.6s 
[root@release-compile debug_gitlab]# docker logs -f gitlab
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=17.10.4-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab editor /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Cleaning stale PIDs & sockets
cat: /var/opt/gitlab/gitlab-rails/VERSION: No such file or directory
Preparing services...
Starting services...
Configuring GitLab...
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
[2025-05-14T23:36:55+00:00] INFO: Started Cinc Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook)
Cinc Client, version 18.3.0
Patents: https://www.chef.io/patents
Infra Phase starting
[2025-05-14T23:36:55+00:00] INFO: *** Cinc Client 18.3.0 ***
[2025-05-14T23:36:55+00:00] INFO: Platform: x86_64-linux
[2025-05-14T23:36:55+00:00] INFO: Cinc-client pid: 28
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/ffi-yajl-2.6.0/lib/ffi_yajl/encoder.rb:42: warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
[2025-05-14T23:36:55+00:00] INFO: Setting the run_list to ["recipe[gitlab]"] from CLI options
[2025-05-14T23:36:55+00:00] INFO: Run List is [recipe[gitlab]]
[2025-05-14T23:36:55+00:00] INFO: Run List expands to [gitlab]
[2025-05-14T23:36:55+00:00] INFO: Starting Cinc Client Run for gitlab666
[2025-05-14T23:36:55+00:00] INFO: Running start handlers
[2025-05-14T23:36:55+00:00] INFO: Start handlers complete.
Resolving cookbooks for run list: ["gitlab"]
[2025-05-14T23:36:56+00:00] INFO: Loading cookbooks [gitlab@0.0.1, package@0.1.0, logrotate@0.1.0, postgresql@0.1.0, redis@0.1.0, monitoring@0.1.0, registry@0.1.0, mattermost@0.1.0, consul@0.1.0, gitaly@0.1.0, praefect@0.1.0, gitlab-kas@0.1.0, gitlab-pages@0.1.0, letsencrypt@0.1.0, nginx@0.1.0, runit@5.1.7, acme@4.1.6, crond@0.1.0]
Synchronizing cookbooks:
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_sshd_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/account_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_mattermost.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_exporter.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_rails.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/README.md in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_shell.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/attributes/default.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/bash_hide_env.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/gitlab_workhorse.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/base_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/authorizer_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/base_pg_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/gitlab_rails_env_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/gitlab_workhorse_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/gitlab_rails.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/geo_pg_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/metrics_exporter_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/pg_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/pg_status_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/helpers/web_server_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/incoming_email.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/logfiles_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/mailroom_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/logging.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/nginx.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/pg_version.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/postgresql.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/redis.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/puma.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/redis_uri.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/patroni.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/rails_migration_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/registry.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/sidekiq.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/smtp_helper.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/metadata.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/libraries/storage_check.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/bootstrap_disable.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/bootstrap.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/database_reindexing_disable.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/config.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/add_trusted_certs.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/database_reindexing_enable.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/default.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/generate_secrets.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/database_migrations.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-healthcheck.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-backup-cli.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-backup-cli_disable.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-rails.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-workhorse_disable.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/gitlab-shell.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/letsencrypt_renew.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/mailroom.rb in the cache.
[2025-05-14T23:36:56+00:00] INFO: Storing updated cookbooks/gitlab/recipes/mailroom_disable.r
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值