如何基于GitLab CE 8.9.6 Docker镜像预设项目默认大小限制?
Got it, let's fix this so you can run your automated repo import without hitting that default 10-project limit. The goal is to set the default project limit to 100 before the container finishes its first initialization—here are two reliable ways to do it:
Method 1: Mount a Custom gitlab.rb Configuration File
GitLab uses the gitlab.rb file to set persistent configs. You can pre-configure this file locally and mount it into the container on startup:
Create a local config directory and
gitlab.rbfile
First, make a folder to hold your GitLab configs (this will also let you persist other settings later):mkdir -p /srv/gitlab/configThen add the project limit line to the
gitlab.rbfile:echo "gitlab_rails['gitlab_default_projects_limit'] = 100" >> /srv/gitlab/config/gitlab.rbStart the GitLab container with the mounted config
Use thisdocker runcommand—note the volume mount for/etc/gitlabpointing to your local config folder:docker run -d \ --name gitlab-ce-8.9.6 \ --publish 443:443 --publish 80:80 --publish 22:22 \ --volume /srv/gitlab/config:/etc/gitlab \ --volume /srv/gitlab/logs:/var/log/gitlab \ --volume /srv/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:8.9.6-ce.0When the container starts, it will use your pre-configured
gitlab.rbinstead of the default, setting the project limit to 100 automatically.
Method 2: Build a Custom Docker Image (Self-Contained)
If you want a self-contained image with the limit pre-set (no external mounts needed), create a custom Dockerfile:
Create a Dockerfile
FROM gitlab/gitlab-ce:8.9.6-ce.0 # Add the project limit config to the default gitlab.rb RUN echo "gitlab_rails['gitlab_default_projects_limit'] = 100" >> /etc/gitlab/gitlab.rbBuild the custom image
docker build -t my-custom-gitlab:8.9.6 .Start the container from your custom image
docker run -d \ --name gitlab-custom \ --publish 443:443 --publish 80:80 --publish 22:22 \ --volume /srv/gitlab/logs:/var/log/gitlab \ --volume /srv/gitlab/data:/var/opt/gitlab \ my-custom-gitlab:8.9.6
Verify the Config Worked
Once the container is fully up (give it 5-10 minutes for initialization), you can confirm the limit is set correctly:
docker exec gitlab-ce-8.9.6 grep gitlab_default_projects_limit /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
You should see output like:
gitlab_default_projects_limit: 100
With this setup, your automated rake repo import will run smoothly without hitting the old 10-project cap—no need to touch the GitLab web UI at all.
内容的提问来源于stack exchange,提问作者OriolesMagic

