doc/administration/docs_self_host.md
{{< details >}}
{{< /details >}}
If you are not able to access the GitLab product documentation at docs.gitlab.com,
you can host the documentation yourself instead.
[!note] The local help of your instance does not include all the docs (for example, it doesn't include docs for GitLab Runner or GitLab Operator), and it's not searchable or browsable. It's intended to only support direct links to specific pages from within your instance.
The URL to the container image you want depends on the version of the GitLab Docs you need. See the following table as a guide for the URL to use in the following sections.
| GitLab version | Container registry | Container image URL |
|---|---|---|
| 17.8 and later | https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/container_registry/8244403 | registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:<version> |
| 15.5 - 17.7 | https://gitlab.com/gitlab-org/gitlab-docs/container_registry/3631228 | registry.gitlab.com/gitlab-org/gitlab-docs/archives:<version> |
| 10.3 - 15.4 | https://gitlab.com/gitlab-org/gitlab-docs/container_registry/631635 | registry.gitlab.com/gitlab-org/gitlab-docs:<version> |
To host the GitLab product documentation, you can use:
The following examples use GitLab 17.8, but make sure to use the version that corresponds to your GitLab instance.
The documentation website is served under the port 4000 inside the container.
In the following example, we expose this on the host under the same port.
Make sure you either:
4000 in your firewall.4000 with a different port number.To run the GitLab product documentation website in a Docker container:
On the server where you host GitLab, or on any other server that your GitLab instance can communicate with:
If you use plain Docker, run:
docker run --detach --name gitlab_docs -it --rm -p 4000:4000 registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
If you host your GitLab instance using
Docker compose,
add the following to your existing docker-compose.yaml:
version: '3.6'
services:
gitlab_docs:
image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
hostname: 'docs.gitlab.example.com'
ports:
- '4000:4000'
Then, pull the changes:
docker-compose up -d
Visit http://0.0.0.0:4000 to view the documentation website and verify that
it works.
You can use GitLab Pages to host the GitLab product documentation.
Prerequisites:
https://example.com/docs/
are not supported.To host the product documentation site with GitLab Pages:
Create a new or edit your existing .gitlab-ci.yml file, and add the following
pages job, while ensuring the version is the same as your GitLab installation:
pages:
image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
script:
- mkdir public
- cp -a /usr/share/nginx/html/* public/
artifacts:
paths:
- public
Optional. Set the GitLab Pages domain name. Depending on the type of the GitLab Pages website, you have two options:
| Type of website | Default domain | Custom domain |
|---|---|---|
| Project website | Not supported | Supported |
| User or group website | Supported | Supported |
[!note] The website you create must be hosted under a subdirectory that matches your installed GitLab version (for example,
17.8/). The Docker images use this version by default.
Because the product documentation site is static, you can take the contents of
/usr/share/nginx/html from inside the container, and use your own web server to host
the documentation wherever you want.
The html directory should be served as is and it has the following structure:
├── 17.8/
├── index.html
In this example:
17.8/ is the directory where the documentation is hosted.index.html is a simple HTML file that redirects to the directory containing the documentation.
In this case, 17.8/.To extract the HTML files of the documentation site:
Create the container that holds the HTML files of the documentation website:
docker create -it --name gitlab_docs registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
Copy the website under /srv/gitlab/:
docker cp gitlab-docs:/usr/share/nginx/html /srv/gitlab/
You end up with a /srv/gitlab/html/ directory that holds the documentation website.
Remove the container:
docker rm -f gitlab_docs
Point your web server to serve the contents of /srv/gitlab/html/.
/help links to the new Docs siteAfter your local product documentation site is running,
redirect the help links
in the GitLab application to your local site, by using the fully qualified domain
name as the documentation URL. For example, if you used the
Docker method, enter http://0.0.0.0:4000.
You don't need to append the version. GitLab detects it and appends it to documentation URL requests as needed. For example, if your GitLab version is 17.8:
http://0.0.0.0:4000/17.8/.<instance_url>/help/administration/settings/help_page#destination-requirements.http://0.0.0.0:4000/17.8/administration/settings/help_page/#destination-requirements.To test the setting, in GitLab, select a Learn more link. For example:
Upgrading the documentation site to a later version requires downloading the newer Docker image tag.
To upgrade to a later version using Docker:
If you use Docker:
Stop the running container:
sudo docker stop gitlab_docs
Remove the existing container:
sudo docker rm gitlab_docs
Pull the new image. For example, 17.8:
docker run --detach --name gitlab_docs -it --rm -p 4000:4000 registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
If you use Docker Compose:
Change the version in docker-compose.yaml, for example 17.8:
version: '3.6'
services:
gitlab_docs:
image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
hostname: 'docs.gitlab.example.com'
ports:
- '4000:4000'
Pull the changes:
docker-compose up -d
To upgrade to a later version using GitLab Pages:
Edit your existing .gitlab-ci.yml file, and replace the image version number:
image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
Commit the changes, push, and GitLab Pages pulls the new documentation site version.
To upgrade to a later version using your own web-server:
Copy the HTML files of the documentation site:
docker create -it --name gitlab_docs registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/archives:17.8
docker cp gitlab_docs:/usr/share/nginx/html /srv/gitlab/
docker rm -f gitlab_docs
Optional. Remove the old site:
rm -r /srv/gitlab/html/17.8/
Local search is included in versions 15.6 and later. If you're using an earlier version, the search doesn't work.
For more information, read about the different types of searches GitLab Docs are using.
If you get an error that the Docker image is not found, check if you're using the correct registry URL.
When previewing the GitLab documentation in Docker on macOS, you may encounter an issue preventing
redirection to the documentation, yielding the message If you are not redirected automatically, click here.
To escape the redirect, you need to append the version number to the URL, such as http://127.0.0.1:4000/16.8/.