Create the container,

# lxc-create -n gitlab -t debian -- -r unstable

If you host is not debian, use download template lxc-create -n gitlab -t download -- --dist debian --release sid

If you want to create a bullseye container, run lxc-create -n gitlab -t download -- --dist debian --release bullseye or lxc-create -n gitlab -t debian -- -r bullseye

# lxc-start -n gitlab
# lxc-attach -n gitlab

See LXC for more details on managing a container. The steps given below are available as an ansible playbook

Note: if you are using a virtual machine, make sure it has at least 4GB ram and 4GB swap space to comfortably run the webpack command during installation.

Note: You may also use systemd-nspawn for creating the container.

Now inside the container,

You will need a utf-8 locale to install postgresql. Run dpkg-reconfigure locales and choose a locale with utf-8 support (for example en_IN.UTF-8). Reboot the container (reboot command) and run lxc-attach again.

  1. Enable contrib section in /etc/apt/sources.list. apt update && apt install gitlab. Note: when gitlab is broken in ustable, install from experimental following instructions given at gitlab.

  2. During installation, choose gitlab.lxc as the hostname. Note: This step is very crucial to able to correctly access the web interface of gitlab. The name you give here has to be present in /etc/hosts of the host system (see below). If you choose localhost or miss the step below, you will get the default nginx page instead of gitlab.

  3. Disable https in debconf wizard as we can't get a certificate without a public IP and registered domain name.
  4. After installation is complete, add ip address of container (ip a will list the ip address) in host machine's /etc/hosts to resolve gitlab.lxc to that of the container. 192.168.122.104 gitlab.lxc # Change ip address

  5. Visit http://gitlab.lxc on host browser