You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For volumes that are provided via a mount bind of a local directory,
the contents are not automatically copied over from the directory
that is getting mounted over. So the entrypoint script will generally
copy all files from a backup data directory into the data directories
that do not yet exist. This way all files should be there but edited
ones not be overwritten.
The defaults.properties file is always copied, since it could contain
new settings upon an upgrade, and it should never be edited by a user.
If running as root, also file ownership is changed to the gitblit
user so that gitblit can read and write data.
Closes#4
Copy file name to clipboardExpand all lines: hub-readme.md
+82-14Lines changed: 82 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -66,29 +66,45 @@ $ sudo docker stop gitblit
66
66
67
67
Gitblit stores two types of data, configuration data and Git repository data. While configuration data is
68
68
relatively static, once the server is configured and has started, the repository data is what you use
69
-
Gitblit for and is written often (unless you use Gitblit only as a repository browser). The docker image
70
-
uses `/var/opt/gitblit` as the base folder for data storage.
69
+
Gitblit for and is written often (unless you use Gitblit only as a repository browser).
70
+
71
+
The docker image uses `/var/opt/gitblit` as the base folder for data storage. Under the base folder, configuration and repository data are separated into two different directories. Configuration data is under `/var/opt/gitblit/etc` and repository data under `/var/opt/gitblit/srv`.
72
+
73
+
```console
74
+
$ docker run -it --rm gitblit/gitblit ls -l /var/opt/gitblit
75
+
total 8
76
+
drwsrws--- 5 gitblit gitblit 4096 Mar 8 16:39 etc
77
+
drwsrws--- 3 gitblit gitblit 4096 Mar 8 16:39 srv
78
+
```
71
79
72
80
To make this data persistent and operation on it more performant, a Docker [volume](https://docs.docker.com/engine/reference/builder/#volume)
73
-
is defined for this path. [Docker manages this volume](https://docs.docker.com/storage/volumes/) automatically
74
-
for you. This is the default and the easiest configuration. The only downside is that the files may be hard to
75
-
locate for you or tools running outside the container. You can make it a little easier by defining a name for
76
-
the volume, when creating the container.
81
+
is defined for the path `/var/opt/gitblit` for the image.
82
+
83
+
84
+
Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the gitblit images to familiarize themselves with the options available, including:
85
+
86
+
* Let Docker manage the storage of your server data [by writing the files to disk on the host system using its own internal volume management](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume). This is the default and is easy and fairly transparent to the user. The downside is that the files may be hard to locate for tools and applications that run directly on the host system, i.e. outside containers.
87
+
* Create a data directory on the host system (outside the container) and [mount this to a directory visible from inside the container](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume). This places the server files in a known location on the host system, and makes it easy for tools and applications on the host system to access the files. The downside is that the user needs to make sure that the directory exists, and that e.g. directory permissions and other security mechanisms on the host system are set up correctly.
88
+
89
+
The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blogs and forum postings that discuss and give advice in this area.
90
+
91
+
#### Data volumes
92
+
[Docker manages this volume](https://docs.docker.com/storage/volumes/) automatically
93
+
for you. This is the default and the easiest configuration. You can make the volume files a little easier to locate by defining a name for the volume, when creating the container (or, even, when creating a volume beforehand).
Under the base directory, configuration and repository data are separated into two different directories.
83
-
Configuration data is under `/var/opt/gitblit/etc` and repository data under `/var/opt/gitblit/srv`. If, for
84
-
some reason, you want to use different volumes for either, e.g. for different kinds of backup, you can attach
85
-
two volumes to these directories.
99
+
If, for some reason, you want to use different volumes for `etc` and `srv`, e.g. for different kinds of backup, you can attach two different volumes to these directories.
Updating with anonymous volumes (no name provided for it) requires you to either find out the volume id from the current running container and reusing that id for the new container, or to use the `--volumes-from` parameter, which requires the old container to still be around.
110
126
127
+
#### Mount bind directories
128
+
129
+
The second option is to mount a local directory on the host into the container via a bind mount. Again, you can choose if you want all of the data in the host directory, or maybe just the configuration data, for easier editing, while the git data is stored in a docker data volume. (Or, vice versa, of course. Or, something completely different.)
130
+
131
+
The container will copy the necessary configuration files, that Gitblit needs to run, into the directory. (While this is done automatically by docker for data volumes, it has to be done explicitly by the container for a bind mount volume.) Existing data is not overwritten (except for the `defaults.properties`file, use this only for reference). The start script will also change ownership of the directory and files to the `gitblit`user because the server process will need to be able to read them and write to some.
For advanced usage under Linux, you may be able to improve performance by moving Gitblit's `temp` folder
115
146
to RAM. Gitblit unpacks web application data on each start into a temporary folder. The default for that
@@ -122,6 +153,43 @@ $ sudo docker run -d --name gitblit --tmpfs /var/opt/gitblit/temp -p 8443:8443 g
122
153
```
123
154
124
155
156
+
## Running as non-root with `--user`
157
+
158
+
The gitblit images will drop root privileges in the start up script and run the Gitblit server process under the unprivileged user `gitblit` with user and group id `8117`. Still, the image allows to directly start a container as a non-root user with the `--user` command line parameter, albeit with some restrictions.
159
+
160
+
If you simply don't want any part to run with root privileges, you can directly start the container as the user `8117`:
What does not work, is to use a different user id. This is because that user id will not have the permissions to write to the files and directories in the container. If you want to run the container as an arbitrary user, you need to provide a bind mount volume and make sure that the ownership and permissions allow the server process to write files. For example, to run under the user `picard`:
167
+
168
+
```console
169
+
$ ls -ls
170
+
total88
171
+
drwxr-x--- 2 picard picard 64 Mar 8 18:07 gitblit-data
172
+
-rwxr-xr-x 2 picard picard 88 Mar 8 18:07 somefile
Another use case is, if you want to use Gitblit only as an attractive repository browser for your local git projects. In that case you can bind mount only your directory with your git projects to `/var/opt/gitblit/srv/git` and run gitblit under your user id. In this case you also need to run it under the gitblit *group* id `8117`, so that the process has access to the other data volumes containing the configuration data.
178
+
179
+
```console
180
+
$ ls -l
181
+
total 0
182
+
drwxr-xr-x 29 anthony staff 928 Feb 28 20:00 gitblit/
183
+
drwxr-xr-x 10 anthony staff 320 Mar 8 18:16 gitblit-docker/
184
+
drwxr-xr-x 12 anthony staff 384 Feb 16 15:26 gitblit-maven/
185
+
drwxr-xr-x 13 anthony staff 416 Feb 16 15:36 ok.sh/
You can then direct your browser to [http://localhost:8080](http://localhost:8080) and directly start browsing your repositories.
191
+
192
+
125
193
## Configuration
126
194
127
195
Configure the gitblit instance by adding your custom settings to the file `gitblit.properties` in the directory `/var/opt/gitblit/etc` in the container. Some options can be controlled by providing environment variables to the container.
0 commit comments