From 2b5007245adfd31e31fd2917902494853ecbc931 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 26 Jun 2015 15:19:58 +0200 Subject: Added data volumes to Dockerfile --- docker/single/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/single/Dockerfile b/docker/single/Dockerfile index a6cbf131237..7e783eaa297 100644 --- a/docker/single/Dockerfile +++ b/docker/single/Dockerfile @@ -23,8 +23,11 @@ RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ && ln -s /opt/gitlab/sv/sshd /opt/gitlab/service \ && mkdir -p /var/run/sshd -# Expose web & ssh -EXPOSE 80 22 +# Expose https & http & ssh +EXPOSE 443 80 22 + +# Define data volumes +VOLUME ["/etc/gitlab", "/var/opt/gitlab", "/var/log/gitlab"] # Copy assets COPY assets/wrapper /usr/local/bin/ -- cgit v1.2.1 From 954c1df256ac867635b31e82a032704e963a10ee Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 29 Jun 2015 17:56:34 +0200 Subject: Update Docker documentation to use single container --- docker/Dockerfile | 45 +++++++++++ docker/README.md | 166 +++++++++++++++++++++-------------------- docker/app/Dockerfile | 32 -------- docker/app/assets/wrapper | 17 ----- docker/assets/wrapper | 16 ++++ docker/data/Dockerfile | 8 -- docker/data/assets/gitlab.rb | 37 --------- docker/fig.yml | 2 + docker/marathon.json | 14 ++++ docker/single/Dockerfile | 37 --------- docker/single/assets/gitlab.rb | 37 --------- docker/single/assets/wrapper | 16 ---- docker/single/marathon.json | 14 ---- docker/troubleshooting.md | 43 +++++++---- 14 files changed, 189 insertions(+), 295 deletions(-) create mode 100644 docker/Dockerfile delete mode 100644 docker/app/Dockerfile delete mode 100755 docker/app/assets/wrapper create mode 100755 docker/assets/wrapper delete mode 100644 docker/data/Dockerfile delete mode 100644 docker/data/assets/gitlab.rb create mode 100644 docker/fig.yml create mode 100644 docker/marathon.json delete mode 100644 docker/single/Dockerfile delete mode 100644 docker/single/assets/gitlab.rb delete mode 100755 docker/single/assets/wrapper delete mode 100644 docker/single/marathon.json diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000000..86f6c896a6d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:14.04 +MAINTAINER Sytse Sijbrandij + +# Install required packages +RUN apt-get update -q \ + && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ + ca-certificates \ + openssh-server \ + wget \ + apt-transport-https \ + vim \ + nano + +# Download & Install GitLab +# If you run GitLab Enterprise Edition point it to a location where you have downloaded it. +RUN echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/gitlab_gitlab-ce.list +RUN wget -q -O - https://packages.gitlab.com/gpg.key | apt-key add - +RUN apt-get update && apt-get install -yq --no-install-recommends gitlab-ce + +# Manage SSHD through runit +RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ + && mkfifo /opt/gitlab/sv/sshd/supervise/ok \ + && printf "#!/bin/sh\nexec 2>&1\numask 077\nexec /usr/sbin/sshd -D" > /opt/gitlab/sv/sshd/run \ + && chmod a+x /opt/gitlab/sv/sshd/run \ + && ln -s /opt/gitlab/sv/sshd /opt/gitlab/service \ + && mkdir -p /var/run/sshd + +# Prepare default configuration +RUN ( \ + echo "" && \ + echo "# Docker options" && \ + echo "# Prevent Postgres from trying to allocate 25% of total memory" && \ + echo "postgresql['shared_buffers'] = '1MB'" ) >> /etc/gitlab/gitlab.rb + +# Expose web & ssh +EXPOSE 443 80 22 + +# Define data volumes +VOLUME ["/etc/gitlab", "/var/opt/gitlab", "/var/log/gitlab"] + +# Copy assets +COPY assets/wrapper /usr/local/bin/ + +# Wrapper to handle signal, trigger runit and reconfigure GitLab +CMD ["/usr/local/bin/wrapper"] diff --git a/docker/README.md b/docker/README.md index 9507aa6a63c..dd86cf6fa69 100644 --- a/docker/README.md +++ b/docker/README.md @@ -11,150 +11,154 @@ After starting a container you can go to [http://localhost:8080/](http://localho It might take a while before the docker container is responding to queries. -You can check the status with something like `sudo docker logs -f 7c10172d7705`. +You can check the status with something like `sudo docker logs -f gitlab`. You can login to the web interface with username `root` and password `password`. Next time, you can just use docker start and stop to run the container. -## How to build the docker images +## Run the image -This guide will also let you know how to build docker images yourself. -Please run all the commands from the GitLab repo root directory. -People using boot2docker should run all the commands without sudo. +Run the image: +```bash +sudo docker run --detach \ + --publish 80443:443 --publish 8080:80 --publish 2222:22 \ + --name gitlab \ + --restart always \ + --volume /srv/gitlab/config:/etc/gitlab \ + --volume /srv/gitlab/logs:/var/log/gitlab \ + --volume /srv/gitlab/data:/var/opt/gitlab \ + gitlab/gitlab-ce:latest +``` -## Choosing between the single and the app and data images +This will start GitLab CE container and expose ports needed to access SSH, HTTP and HTTPS. +All GitLab data will be stored as subdirectories of `/srv/gitlab/`. +The container will automatically `restart` after system reboot. -Normally docker uses a single image for one applications. -But GitLab stores repositories and uploads in the filesystem. -This means that upgrades of a single image are hard. -That is why we recommend using separate app and data images. -We'll first describe how to use a single image. -After that we'll describe how to use the app and data images. +After this you can login to the web interface as explained above in 'After starting a container'. -## Single image +## Build and publish the image -Get a published image from Dockerhub: +This guide will also let you know how to build docker image yourself. +Please run all the commands from the GitLab repo root directory. +People using boot2docker should run all the commands without sudo. ```bash -sudo docker pull sytse/gitlab-ce:7.10.1 +sudo docker build --tag gitlab/gitlab-ce:latest ``` -Run the image: +## Where is the data stored? -```bash -sudo docker run --detach --publish 8080:80 --publish 2222:22 sytse/gitlab-ce:7.10.1 -``` +The GitLab container uses host mounted volumes to store persistent data: +- `/srv/gitlab/data` mounted as `/var/opt/gitlab` in the container is used for storing *application data* +- `/srv/gitlab/logs` mounted as `/var/log/gitlab` in the container is used for storing *logs* +- `/srv/gitlab/config` mounted as `/etc/gitlab` in the container is used for storing *configuration* -After this you can login to the web interface as explained above in 'After starting a container'. +You can fine tune these directories to meet your requirements. + +### Configure GitLab -Build the image: +This container uses the official Omnibus GitLab distribution, so all configuration is done in the unique configuration file `/etc/gitlab/gitlab.rb`. +To access GitLab configuration, you can start an bash in a new the context of running container, you will be able to browse all directories and use your favorite text editor: ```bash -sudo docker build --tag sytse/gitlab-ce:7.10.1 docker/single/ +sudo docker exec -it gitlab /bin/bash ``` -Publish the image to Dockerhub: - +You can also edit just `/etc/gitlab/gitlab.rb`: ```bash -sudo docker push sytse/gitlab-ce +sudo docker exec -it gitlab vi /etc/gitlab/gitlab.rb ``` -Diagnosing commands: +**You should set the `external_url` to point to a valid URL.** + +**To receive e-mails from GitLab you have to configure the [SMTP settings](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md), +because Docker image doesn't have a SMTP server.** + +**Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab: ```bash -sudo docker run -i -t sytse/gitlab-ce:7.10.1 -sudo docker run -ti -e TERM=linux --name gitlab-ce-troubleshoot --publish 8080:80 --publish 2222:22 sytse/gitlab-ce:7.10.1 bash /usr/local/bin/wrapper +sudo docker restart gitlab ``` -## App and data images +For more options for configuring the container please check [Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). -### Get published images from Dockerhub +## Diagnose potential problems +Read container logs: ```bash -sudo docker pull sytse/gitlab-data -sudo docker pull sytse/gitlab-app:7.10.1 +sudo docker logs gitlab ``` -### Run the images - +Enter running container: ```bash -sudo docker run --name gitlab-data sytse/gitlab-data /bin/true -sudo docker run --detach --name gitlab-app --publish 8080:80 --publish 2222:22 --volumes-from gitlab-data sytse/gitlab-app:7.10.1 +sudo docker exec -it gitlab /bin/bash ``` -After this you can login to the web interface as explained above in 'After starting a container'. +From within container you can administrer GitLab container as you would normally administer Omnibus installation: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md. -### Build images - -Build your own based on the Omnibus packages with the following commands. +### Upgrade GitLab to newer version +To upgrade GitLab to new version you have to do: +1. pull new image, ```bash -sudo docker build --tag gitlab-data docker/data/ -sudo docker build --tag gitlab-app:7.10.1 docker/app/ +sudo docker stop gitlab ``` -After this run the images: - +1. stop running container, ```bash -sudo docker run --name gitlab-data gitlab-data /bin/true -sudo docker run --detach --name gitlab-app --publish 8080:80 --publish 2222:22 --volumes-from gitlab-data gitlab-app:7.10.1 +sudo docker rm gitlab ``` -We assume using a data volume container, this will simplify migrations and backups. -This empty container will exist to persist as volumes the 3 directories used by GitLab, so remember not to delete it. - -The directories on data container are: - -- `/var/opt/gitlab` for application data -- `/var/log/gitlab` for logs -- `/etc/gitlab` for configuration - -### Configure GitLab - -This container uses the official Omnibus GitLab distribution, so all configuration is done in the unique configuration file `/etc/gitlab/gitlab.rb`. - -To access GitLab configuration, you can start an interactive command line in a new container using the shared data volume container, you will be able to browse the 3 directories and use your favorite text editor: +1. remove existing container, +```bash +sudo docker pull gitlab/gitlab-ce:latest +``` +1. create the container once again with previously specified options. ```bash -sudo docker run -ti -e TERM=linux --rm --volumes-from gitlab-data ubuntu -vi /etc/gitlab/gitlab.rb +sudo docker run --detach \ + --publish 80443:443 --publish 8080:80 --publish 2222:22 \ + --name gitlab \ + --restart always \ + --volume /srv/gitlab/config:/etc/gitlab \ + --volume /srv/gitlab/logs:/var/log/gitlab \ + --volume /srv/gitlab/data:/var/opt/gitlab \ + gitlab/gitlab-ce:latest ``` -**Note** that GitLab will reconfigure itself **at each container start.** You will need to restart the container to reconfigure your GitLab. +On the first run GitLab will reconfigure and update itself. -You can find all available options in [Omnibus GitLab documentation](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration). +### Run GitLab CE on public IP address -### Upgrade GitLab with app and data images +You can make Docker to use your IP address and forward all traffic to the GitLab CE container. +You can do that by modifying the `--publish` ((Binding container ports to the host)[https://docs.docker.com/articles/networking/#binding-ports]): -To upgrade GitLab to new versions, stop running container, create new docker image and container from that image. +> --publish=[] : Publish a container᾿s port or a range of ports to the host format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort -It Assumes that you're upgrading from 7.8.1 to 7.10.1 and you're in the updated GitLab repo root directory: +To expose GitLab CE on IP 1.1.1.1: ```bash -sudo docker stop gitlab-app -sudo docker rm gitlab-app -sudo docker build --tag gitlab-app:7.10.1 docker/app/ -sudo docker run --detach --name gitlab-app --publish 8080:80 --publish 2222:22 --volumes-from gitlab-data gitlab-app:7.10.1 +sudo docker run --detach \ + --publish 1.1.1.1:443:443 --publish 1.1.1.1:80:80 --publish 1.1.1.1:22:22 \ + --name gitlab \ + --restart always \ + --volume /srv/gitlab/config:/etc/gitlab \ + --volume /srv/gitlab/logs:/var/log/gitlab \ + --volume /srv/gitlab/data:/var/opt/gitlab \ + gitlab/gitlab-ce:latest ``` -On the first run GitLab will reconfigure and update itself. If everything runs OK don't forget to cleanup the app image: - -```bash -sudo docker rmi gitlab-app:7.8.1 -``` +You can then access GitLab instance at http://1.1.1.1/ and https://1.1.1.1/. ### Publish images to Dockerhub - Ensure the containers are running - Login to Dockerhub with `sudo docker login` -- Run the following (replace '7.10.1' with the version you're using and 'Sytse Sijbrandij' with your name): ```bash -sudo docker commit -m "Initial commit" -a "Sytse Sijbrandij" gitlab-app sytse/gitlab-app:7.10.1 -sudo docker push sytse/gitlab-app:7.10.1 -sudo docker commit -m "Initial commit" -a "Sytse Sijbrandij" gitlab-data sytse/gitlab-data -sudo docker push sytse/gitlab-data +sudo docker login +sudo docker push gitlab/gitlab-ce:latest ``` ## Troubleshooting diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile deleted file mode 100644 index fe3f7f0bcd2..00000000000 --- a/docker/app/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM ubuntu:14.04 - -# Install required packages -RUN apt-get update -q \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qy --no-install-recommends \ - ca-certificates \ - openssh-server \ - wget \ - apt-transport-https - -# Download & Install GitLab -# If you run GitLab Enterprise Edition point it to a location where you have downloaded it. -RUN echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/gitlab_gitlab-ce.list -RUN wget -q -O - https://packages.gitlab.com/gpg.key | apt-key add - -RUN apt-get update && apt-get install -yq --no-install-recommends gitlab-ce - -# Manage SSHD through runit -RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ - && mkfifo /opt/gitlab/sv/sshd/supervise/ok \ - && printf "#!/bin/sh\nexec 2>&1\numask 077\nexec /usr/sbin/sshd -D" > /opt/gitlab/sv/sshd/run \ - && chmod a+x /opt/gitlab/sv/sshd/run \ - && ln -s /opt/gitlab/sv/sshd /opt/gitlab/service \ - && mkdir -p /var/run/sshd - -# Expose web & ssh -EXPOSE 80 22 - -# Copy assets -COPY assets/wrapper /usr/local/bin/ - -# Wrapper to handle signal, trigger runit and reconfigure GitLab -CMD ["/usr/local/bin/wrapper"] \ No newline at end of file diff --git a/docker/app/assets/wrapper b/docker/app/assets/wrapper deleted file mode 100755 index 9e6e7a05903..00000000000 --- a/docker/app/assets/wrapper +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -function sigterm_handler() { - echo "SIGTERM signal received, try to gracefully shutdown all services..." - gitlab-ctl stop -} - -trap "sigterm_handler; exit" TERM - -function entrypoint() { - # Default is to run runit and reconfigure GitLab - gitlab-ctl reconfigure & - /opt/gitlab/embedded/bin/runsvdir-start & - wait -} - -entrypoint diff --git a/docker/assets/wrapper b/docker/assets/wrapper new file mode 100755 index 00000000000..966b2cab4a1 --- /dev/null +++ b/docker/assets/wrapper @@ -0,0 +1,16 @@ +#!/bin/bash + +function sigterm_handler() { + echo "SIGTERM signal received, try to gracefully shutdown all services..." + gitlab-ctl stop +} + +trap "sigterm_handler; exit" TERM + +function entrypoint() { + /opt/gitlab/embedded/bin/runsvdir-start & + gitlab-ctl reconfigure # will also start everything + gitlab-ctl tail # tail all logs +} + +entrypoint diff --git a/docker/data/Dockerfile b/docker/data/Dockerfile deleted file mode 100644 index ea0175c4aa2..00000000000 --- a/docker/data/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM busybox - -# Declare volumes -VOLUME ["/var/opt/gitlab", "/var/log/gitlab", "/etc/gitlab"] -# Copy assets -COPY assets/gitlab.rb /etc/gitlab/ - -CMD /bin/sh diff --git a/docker/data/assets/gitlab.rb b/docker/data/assets/gitlab.rb deleted file mode 100644 index 7fddf309c01..00000000000 --- a/docker/data/assets/gitlab.rb +++ /dev/null @@ -1,37 +0,0 @@ -# External URL should be your Docker instance. -# By default, this example is the "standard" boot2docker IP. -# Always use port 80 here to force the internal nginx to bind port 80, -# even if you intend to use another port in Docker. -external_url "http://192.168.59.103/" - -# Prevent Postgres from trying to allocate 25% of total memory -postgresql['shared_buffers'] = '1MB' - -# Configure GitLab to redirect PostgreSQL logs to the data volume -postgresql['log_directory'] = '/var/log/gitlab/postgresql' - -# Some configuration of GitLab -# You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration -gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' -gitlab_rails['gitlab_support_email'] = 'support@example.com' -gitlab_rails['time_zone'] = 'Europe/Paris' - -# SMTP settings -# You must use an external server, the Docker container does not install an SMTP server -gitlab_rails['smtp_enable'] = true -gitlab_rails['smtp_address'] = "smtp.example.com" -gitlab_rails['smtp_port'] = 587 -gitlab_rails['smtp_user_name'] = "user" -gitlab_rails['smtp_password'] = "password" -gitlab_rails['smtp_domain'] = "example.com" -gitlab_rails['smtp_authentication'] = "plain" -gitlab_rails['smtp_enable_starttls_auto'] = true - -# Enable LDAP authentication -# gitlab_rails['ldap_enabled'] = true -# gitlab_rails['ldap_host'] = 'ldap.example.com' -# gitlab_rails['ldap_port'] = 389 -# gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain' -# gitlab_rails['ldap_allow_username_or_email_login'] = false -# gitlab_rails['ldap_uid'] = 'uid' -# gitlab_rails['ldap_base'] = 'ou=users,dc=example,dc=com' diff --git a/docker/fig.yml b/docker/fig.yml new file mode 100644 index 00000000000..989551cbfe2 --- /dev/null +++ b/docker/fig.yml @@ -0,0 +1,2 @@ +app: + build: . diff --git a/docker/marathon.json b/docker/marathon.json new file mode 100644 index 00000000000..d23c2b84e0e --- /dev/null +++ b/docker/marathon.json @@ -0,0 +1,14 @@ +{ + "id": "/gitlab", + "ports": [0,0], + "cpus": 2, + "mem": 2048.0, + "disk": 10240.0, + "container": { + "type": "DOCKER", + "docker": { + "network": "HOST", + "image": "sytse/gitlab-ce:7.10.1" + } + } +} \ No newline at end of file diff --git a/docker/single/Dockerfile b/docker/single/Dockerfile deleted file mode 100644 index 7e783eaa297..00000000000 --- a/docker/single/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Sytse Sijbrandij - -# Install required packages -RUN apt-get update -q \ - && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - ca-certificates \ - openssh-server \ - wget \ - apt-transport-https - -# Download & Install GitLab -# If you run GitLab Enterprise Edition point it to a location where you have downloaded it. -RUN echo "deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/gitlab_gitlab-ce.list -RUN wget -q -O - https://packages.gitlab.com/gpg.key | apt-key add - -RUN apt-get update && apt-get install -yq --no-install-recommends gitlab-ce - -# Manage SSHD through runit -RUN mkdir -p /opt/gitlab/sv/sshd/supervise \ - && mkfifo /opt/gitlab/sv/sshd/supervise/ok \ - && printf "#!/bin/sh\nexec 2>&1\numask 077\nexec /usr/sbin/sshd -D" > /opt/gitlab/sv/sshd/run \ - && chmod a+x /opt/gitlab/sv/sshd/run \ - && ln -s /opt/gitlab/sv/sshd /opt/gitlab/service \ - && mkdir -p /var/run/sshd - -# Expose https & http & ssh -EXPOSE 443 80 22 - -# Define data volumes -VOLUME ["/etc/gitlab", "/var/opt/gitlab", "/var/log/gitlab"] - -# Copy assets -COPY assets/wrapper /usr/local/bin/ -COPY assets/gitlab.rb /etc/gitlab/ - -# Wrapper to handle signal, trigger runit and reconfigure GitLab -CMD ["/usr/local/bin/wrapper"] diff --git a/docker/single/assets/gitlab.rb b/docker/single/assets/gitlab.rb deleted file mode 100644 index ef84e7832d6..00000000000 --- a/docker/single/assets/gitlab.rb +++ /dev/null @@ -1,37 +0,0 @@ -# External URL should be your Docker instance. -# By default, GitLab will use the Docker container hostname. -# Always use port 80 here to force the internal nginx to bind port 80, -# even if you intend to use another port in Docker. -# external_url "http://192.168.59.103/" - -# Prevent Postgres from trying to allocate 25% of total memory -postgresql['shared_buffers'] = '1MB' - -# Configure GitLab to redirect PostgreSQL logs to the data volume -postgresql['log_directory'] = '/var/log/gitlab/postgresql' - -# Some configuration of GitLab -# You can find more at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#configuration -gitlab_rails['gitlab_email_from'] = 'gitlab@example.com' -gitlab_rails['gitlab_support_email'] = 'support@example.com' -gitlab_rails['time_zone'] = 'Europe/Paris' - -# SMTP settings -# You must use an external server, the Docker container does not install an SMTP server -gitlab_rails['smtp_enable'] = true -gitlab_rails['smtp_address'] = "smtp.example.com" -gitlab_rails['smtp_port'] = 587 -gitlab_rails['smtp_user_name'] = "user" -gitlab_rails['smtp_password'] = "password" -gitlab_rails['smtp_domain'] = "example.com" -gitlab_rails['smtp_authentication'] = "plain" -gitlab_rails['smtp_enable_starttls_auto'] = true - -# Enable LDAP authentication -# gitlab_rails['ldap_enabled'] = true -# gitlab_rails['ldap_host'] = 'ldap.example.com' -# gitlab_rails['ldap_port'] = 389 -# gitlab_rails['ldap_method'] = 'plain' # 'ssl' or 'plain' -# gitlab_rails['ldap_allow_username_or_email_login'] = false -# gitlab_rails['ldap_uid'] = 'uid' -# gitlab_rails['ldap_base'] = 'ou=users,dc=example,dc=com' diff --git a/docker/single/assets/wrapper b/docker/single/assets/wrapper deleted file mode 100755 index 966b2cab4a1..00000000000 --- a/docker/single/assets/wrapper +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -function sigterm_handler() { - echo "SIGTERM signal received, try to gracefully shutdown all services..." - gitlab-ctl stop -} - -trap "sigterm_handler; exit" TERM - -function entrypoint() { - /opt/gitlab/embedded/bin/runsvdir-start & - gitlab-ctl reconfigure # will also start everything - gitlab-ctl tail # tail all logs -} - -entrypoint diff --git a/docker/single/marathon.json b/docker/single/marathon.json deleted file mode 100644 index d23c2b84e0e..00000000000 --- a/docker/single/marathon.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "id": "/gitlab", - "ports": [0,0], - "cpus": 2, - "mem": 2048.0, - "disk": 10240.0, - "container": { - "type": "DOCKER", - "docker": { - "network": "HOST", - "image": "sytse/gitlab-ce:7.10.1" - } - } -} \ No newline at end of file diff --git a/docker/troubleshooting.md b/docker/troubleshooting.md index 5827f2185db..63482547daa 100644 --- a/docker/troubleshooting.md +++ b/docker/troubleshooting.md @@ -9,24 +9,19 @@ postgresql['log_directory'] = '/var/log/gitlab/postgresql' # Commands ```bash -sudo docker build --tag gitlab_image docker/ +sudo docker build --tag gitlab/gitlab-ce:latest docker/ -sudo docker rm -f gitlab_app -sudo docker rm -f gitlab_data +sudo docker rm -f gitlab -sudo docker run --name gitlab_data gitlab_image /bin/true +sudo docker exec -it gitlab vim /etc/gitlab/gitlab.rb -sudo docker run -ti --rm --volumes-from gitlab_data ubuntu apt-get update && sudo apt-get install -y vim && sudo vim /etc/gitlab/gitlab.rb +sudo docker exec gitlab tail -f /var/log/gitlab/reconfigure.log -sudo docker run --detach --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image +sudo docker exec gitlab tail -f /var/log/gitlab/postgresql/current -sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/reconfigure.log +sudo docker exec gitlab cat /var/opt/gitlab/postgresql/data/postgresql.conf | grep shared_buffers -sudo docker run -t --rm --volumes-from gitlab_data ubuntu tail -f /var/log/gitlab/postgresql/current - -sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /var/opt/gitlab/postgresql/data/postgresql.conf | grep shared_buffers - -sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /etc/gitlab/gitlab.rb +sudo docker exec gitlab cat /etc/gitlab/gitlab.rb ``` # Interactively @@ -37,7 +32,16 @@ sudo docker run -t --rm --volumes-from gitlab_data ubuntu cat /etc/gitlab/gitlab # - we run interactively (-t -i) # - we define TERM=linux because it allows to use arrow keys in vi (!!!) # - we choose another startup command (bash) -sudo docker run -ti -e TERM=linux --name gitlab_app --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data gitlab_image bash +sudo docker run --ti \ + -e TERM=linux + --publish 80443:443 --publish 8080:80 --publish 2222:22 \ + --name gitlab \ + --restart always \ + --volume /srv/gitlab/config:/etc/gitlab \ + --volume /srv/gitlab/logs:/var/log/gitlab \ + --volume /srv/gitlab/data:/var/opt/gitlab \ + gitlab/gitlab-ce:latest \ + bash # Configure GitLab to redirect PostgreSQL logs echo "postgresql['log_directory'] = '/var/log/gitlab/postgresql'" >> /etc/gitlab/gitlab.rb @@ -64,10 +68,17 @@ free -m # Cleanup -Remove ALL docker containers and images (also non GitLab ones): +Remove ALL docker containers and images (also non GitLab ones). +**Be careful, because the `-v` also removes volumes attached to the images.** -``` -docker rm $(docker ps -a -q) +```bash +# Remove all containers with attached volumes +docker rm -v $(docker ps -a -q) + +# Remove all images docker rmi $(docker images -q) + +# Remove GitLab persistent data +rm -rf /srv/gitlab ``` -- cgit v1.2.1 From d999e414b98e5ed5c634cb6f964de8ef7595c69f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 6 Jul 2015 16:32:59 +0200 Subject: Final touches --- docker/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docker/README.md b/docker/README.md index dd86cf6fa69..b3dd18c2cdf 100644 --- a/docker/README.md +++ b/docker/README.md @@ -31,22 +31,12 @@ sudo docker run --detach \ gitlab/gitlab-ce:latest ``` -This will start GitLab CE container and expose ports needed to access SSH, HTTP and HTTPS. +This will download and start GitLab CE container and publish ports needed to access SSH, HTTP and HTTPS. All GitLab data will be stored as subdirectories of `/srv/gitlab/`. The container will automatically `restart` after system reboot. After this you can login to the web interface as explained above in 'After starting a container'. -## Build and publish the image - -This guide will also let you know how to build docker image yourself. -Please run all the commands from the GitLab repo root directory. -People using boot2docker should run all the commands without sudo. - -```bash -sudo docker build --tag gitlab/gitlab-ce:latest -``` - ## Where is the data stored? The GitLab container uses host mounted volumes to store persistent data: @@ -151,7 +141,17 @@ sudo docker run --detach \ You can then access GitLab instance at http://1.1.1.1/ and https://1.1.1.1/. -### Publish images to Dockerhub +### Build the image + +This guide will also let you know how to build docker image yourself. +Please run the command from the GitLab repo root directory. +People using boot2docker should run all the commands without sudo. + +```bash +sudo docker build --tag gitlab/gitlab-ce:latest docker/ +``` + +### Publish the image to Dockerhub - Ensure the containers are running - Login to Dockerhub with `sudo docker login` -- cgit v1.2.1 From e906008eb82ce04534fd72fd6013ed7ef79fda1e Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 6 Jul 2015 16:57:46 +0200 Subject: Fix port 80443 => 8443 --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index b3dd18c2cdf..507d88e0e71 100644 --- a/docker/README.md +++ b/docker/README.md @@ -22,7 +22,7 @@ Next time, you can just use docker start and stop to run the container. Run the image: ```bash sudo docker run --detach \ - --publish 80443:443 --publish 8080:80 --publish 2222:22 \ + --publish 8443:443 --publish 8080:80 --publish 2222:22 \ --name gitlab \ --restart always \ --volume /srv/gitlab/config:/etc/gitlab \ -- cgit v1.2.1 From 7a3b47ff473986c9aea730f6cf3ef99ff0c1d450 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jul 2015 12:57:43 +0200 Subject: Fix port issue --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 507d88e0e71..7b27e980473 100644 --- a/docker/README.md +++ b/docker/README.md @@ -108,7 +108,7 @@ sudo docker pull gitlab/gitlab-ce:latest 1. create the container once again with previously specified options. ```bash sudo docker run --detach \ - --publish 80443:443 --publish 8080:80 --publish 2222:22 \ + --publish 8443:443 --publish 8080:80 --publish 2222:22 \ --name gitlab \ --restart always \ --volume /srv/gitlab/config:/etc/gitlab \ -- cgit v1.2.1 From ea7b31002e24f7e3ae473f1419efd1f65fc28b43 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jul 2015 13:06:41 +0200 Subject: Add note about HTTPS --- docker/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/README.md b/docker/README.md index 7b27e980473..eb74bea9950 100644 --- a/docker/README.md +++ b/docker/README.md @@ -62,6 +62,8 @@ sudo docker exec -it gitlab vi /etc/gitlab/gitlab.rb **You should set the `external_url` to point to a valid URL.** +**You may also be interesting in [Enabling HTTPS](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#enable-https).** + **To receive e-mails from GitLab you have to configure the [SMTP settings](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md), because Docker image doesn't have a SMTP server.** -- cgit v1.2.1 From b8c9c69e5ae7ffd382c06007f136aede9631f886 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Jul 2015 14:03:18 +0200 Subject: Markdown fix --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index eb74bea9950..9cd48bf87d4 100644 --- a/docker/README.md +++ b/docker/README.md @@ -124,7 +124,7 @@ On the first run GitLab will reconfigure and update itself. ### Run GitLab CE on public IP address You can make Docker to use your IP address and forward all traffic to the GitLab CE container. -You can do that by modifying the `--publish` ((Binding container ports to the host)[https://docs.docker.com/articles/networking/#binding-ports]): +You can do that by modifying the `--publish` ([Binding container ports to the host](https://docs.docker.com/articles/networking/#binding-ports)): > --publish=[] : Publish a container᾿s port or a range of ports to the host format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort -- cgit v1.2.1