Skip to content

Instantly share code, notes, and snippets.

@olegchir
Created October 21, 2014 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegchir/273a36f4acf67a7be11e to your computer and use it in GitHub Desktop.
Save olegchir/273a36f4acf67a7be11e to your computer and use it in GitHub Desktop.

Ubuntu host and container

Install LXC:

apt-get install linux-hwe-generic # update to 3.13 on Precise
apt-add-repository ppa:ubuntu-lxc/stable
apt-get update
apt-get install lxc lxc-templates cgmanager cgroup-lite
reboot

Create Ubuntu container

lxc-create -n gitlab -t ubuntu-cloud \
  -B lvm --vgname sdbvg --fssize 3G \ # optional, use LVM
  -- -r precise -s daily # optional, use 12.04 with latest updates
  # add
  #   -T https://cloud-images.ubuntu.com/precise/20140821/precise-server-cloudimg-amd64-root.tar.gz
  # in case lxc-create cannot find ubuntu-cloudimg-query or do
  #   apt-get install cloud-utils
lxc-start -n gitlab -d
lxc-ls -f # add 'IP gitlab.lxc' to /etc/hosts
lxc-attach -n gitlab

Inside the container

apt-get install openssh-server postfix
wget https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_7.1.1-omnibus.1-1_amd64.deb
dpkg -i gitlab_7.1.1-omnibus.1-1_amd64.deb
nano /etc/gitlab/gitlab.rb
# external_url 'http://gitlab.lxc'
gitlab-ctl reconfigure

Open http://gitlab.lxc and login with user / pass: root / 5iveL!fe

openSUSE host and container

(openSUSE host is used because zypper is required to bootstrap rootfs)

Install LXC

zypper rm lxc
zypper ar http://download.opensuse.org/repositories/Kernel:/stable/standard/Kernel:stable.repo
zypper ar http://download.opensuse.org/repositories/Virtualization/openSUSE_13.1/Virtualization.repo    
zypper dup --from Kernel_stable
zypper in lxc build
cat >/etc/lxc/default.conf <<EOF
lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
EOF
yast
# create br0 bridge, attach it to eth0, and move IP config to br0
systemctl enable lxc
reboot

Create openSUSE container

lxc-create -n gitlab -t opensuse
lxc-start -n gitlab -d
lxc-ls -f # add 'IP gitlab.lxc' to /etc/hosts
lxc-attach -n gitlab

Inside the container

zypper in wget less timezone
wget http://downloads.bitnami.com/files/stacks/gitlab/7.1.1-0/bitnami-gitlab-7.1.1-0-linux-x64-installer.run
chmod +x bitnami-gitlab-*.run 
./bitnami-gitlab-*.run
# answer gitlab.lxc to Domain question

Open http://gitlab.lxc and login.

Virtualization beware

In case the host itself is running under some kind of virtualization, then container won't be able to receive IP address from DHCP with default settings. Go to network adapter options and allow Promiscuous Mode (link). Bridged mode is also recommended for simplicity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment