How to Quickly Deploy a Private GitLab Server with Docker
This guide walks through installing a private GitLab server using Docker, covering image retrieval, container launch with port and volume mappings, external URL configuration, initial setup, project creation, and client-side testing with Git commands to verify the deployment.
1. Introduction to GitLab
GitLab is an open-source Git-based code repository system.
The biggest difference from GitHub is that it allows you to set up your own private Git repository.
2. Installation
Installing GitLab directly is complex because it requires many dependencies such as Redis, Nginx, a database, etc.
To simplify the process, GitLab provides a Docker image that can be started quickly.
Specific steps:
(1) Configure Docker registry mirror
Pulling from Docker Hub can be slow, so a mirror is needed.
I use the accelerator provided by daocloud.io for fast speed.
(2) Pull GitLab image
docker pull gitlab/gitlab-ceAfter download, list images: docker images The list shows the GitLab image, e.g.
docker.io/gitlab/gitlab-ce …(3) Start the container
sudo docker run --detach \
--hostname gitlab \
--publish 443:443 \
--publish 80:80 \
--publish 2222:22 \
--name gitlab \
--restart always \
--volume /root/data/gitlab/config:/etc/gitlab \
--volume /root/data/gitlab/logs:/var/log/gitlab \
--volume /root/data/gitlab/data:/var/opt/gitlab \
docker.io/gitlab/gitlab-ceThe three --publish options map container ports to host ports for HTTP, HTTPS, and SSH.
The three --volume options map data volumes for GitLab configuration, logs, and data.
(4) Configure external URL
Edit the GitLab configuration file: docker exec -it gitlab vi /etc/gitlab/gitlab.rb Find the external_url line and set it to your server address, e.g. external_url 'http://114.215.223.62' Save and restart the container:
docker restart gitlab(5) Access
GitLab is now installed and running; you can access it via the configured URL.
3. Configuration
On first login, GitLab asks to reset the admin password. After resetting, log in.
Create a new project by entering a name and description.
4. Client testing
(1) Global settings
GitLab project page provides global configuration commands, e.g.
git config --global user.name "Administrator"
git config --global user.email "[email protected]"(2) Clone the newly created project
git clone http://114.215.223.62/root/test.git(3) Modify the project, add a README
cd test
vi README.md # write "test"
git add README.md
git commit -m "add README"(4) Push to the repository
git push -u origin masterThe changes appear in GitLab, confirming the environment works.
GitLab documentation: https://docs.gitlab.com/ce/README.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
