VERSION ORIGINAL EN ESPAÑOL EN EL SIGUIENTE POST.
ORIGINAL VERSION IN SPANISH IN THE FOLLOWING POST.
This guide aims to establish a method to install an application in docker successfully, avoiding permissions, volumes or ports problems.
- It is assumed that the user has already configured their OMV system and
its file system for data (in this guide it will be the "DATA"
folder). SSH access is assumed to be enabled and available with the
root user and password set during OMV installation.
- If you need help https://openmediavault.readthe…_guide/newuserguide.html# . For SSH: in the OMV GUI section <<Services>> then <<SSH>> then click on "Enable" and click on "Save". Install Putty for remote access (https://www.putty.org/)
Docker is a technology that enables the creation and use of Linux containers. A container is one or more applications and their dependencies, grouped and isolated from each other, that run on the same operating system kernel. Docker allows us to install, uninstall, modify, update applications as many times as we want without causing damage to the system.
To use docker we need to define the following parameters:
in our file system where we will host the containers. A 60GB or larger SSD
is recommended, independent of our data file system. We gain speed
and security. We divide this space into two parts, dedicated to
PROGRAM files and CONFIGURATION files.
- PROGRAM FILES: They are downloaded and configured automatically, they are "expendable", they can be easily downloaded and installed again. It is a good idea to place them outside of the OMV system disk to avoid problems. We will save them in a folder that we will call "docker".
- CONFIGURATION FILES: They are created, modified and customized during the use of the application. Passwords, personal settings, databases, etc. depending on the case. These files are irreplaceable, we must keep them if we want to always keep the application in the same state. We will save them in a folder that we will call "config". It is a good idea to make regular backups of this folder.
- A USER to run docker with. For security reasons, it is convenient to do it this way so as not to grant the application more permissions than necessary. In this guide it will be "userapp", and he must have access to the space that we dedicate to docker and the data used by the application.
1. Install an SSD disk for docker. Install OMV-Extras
- To install a disk see: https://openmediavault.readthe…de.html#data-drive-set-up
- To install OMV-Extras see: OMV-Extras.org Plugin
2. To facilitate access to the disks we create two symbolic links /SSD and /DATA
- In the OMV GUI we go to the section <<System>> then <<Plugins>> we look for the plugin "openmediavault-symlinks" and we select it and click "+ Install" in the upper menu.
- In the section <<Storage>> then <<File system>>, we open the column "Mount point" and we look at which is the mounting point of the SSD disk.
- In the section <<Services>> then <<Symlinks>> click on "+ Add".
- In the window we click on the folder icon to the right of "origin", we look for the mounting path of the SSD disk and we select it. In "Destination" we write /SSD and press save.
- We repeat the process in our file system with the folder where we have the data and create the symbolic link /DATA
3. Create folders for Docker files.
- We open a terminal in putty with the root user and type:
mkdir -m 770 /SSD/config
chgrp users /SSD/config
4. Change the location of the docker PROGRAM files to the "docker" folder on the SSD. Install Docker and Portainer.
- In the OMV GUI, go to the <<OMV-Extras>> section, click on the "Docker" tab and in the "Dockers Storage" field replace the value with the path of the "docker" folder. A symlink will no work here. Example: /srv/dev-disk-by-uuid-861acf8c-761a-4b60-9123-3aa98d445f7d/docker
- Install docker: Click on the "Docker" tab in the top menu and click on "Install".
- Install Portainer: Click on the "Portainer" tab in the top menu and click on "Install".
5. Create the user "userapp".
- In the OMV GUI we go to the <<Access Permissions>> section, then <<User>> click on "+ Add" and create the user "userapp", previously adding it to the groups "user" and "docker" in the "Groups" tab".
- We open the UID and GID columns and take note of the values that the user "userapp" has. Example UID=1002 GID=100 This may vary on your system
6. Choose an stack
- On the web https://hub.docker.com/search?type=image there are thousands of containers ready to configure. Whenever possible, choose containers from trusted publishers or with many downloads and current.
- We chose the Jellyfin container as an example. In the search engine many results appear, we choose the one for linuxserver. https://hub.docker.com/r/linuxserver/jellyfin
- We find the docker-compose stack and copy it to a text file. In this case:
Note: Verify on the official page that this stack has not changed before installing it.
7. Customize the stack.
- It is always a good idea to read the editor's comments to familiarize yourself with the options and to verify that the container is valid for our architecture.
- We customize our stack to suit our system. In this example, we remove all optional lines and keep the essentials. We assume as an example that within /DATA we have the "media" folder that contains other subfolders with movies, photos, etc.
- We adjust the stack as follows:
- Comment 1: See point 5.
- Comment 2: Adjust it to your location. You can see it by typing cat/etc/timezone in a terminal.
the "volumes" section we tell the application where we
want it to write and read information. The syntax means that to the
left of ":" we define the real path of the disk and to the
right is the corresponding folder within the container.
- Therefore, in the first line we tell the application that the configuration files are written to our SSD in the "config" folder and also another subfolder called "Jellyfin". Defined like this, we will have subfolders for each container with its configuration files inside the config folder. It is not necessary to create the "Jellyfin" folder beforehand, docker can create up to one level of subfolders when the container starts.
- In the second line we tell the application where the data to be used, movies, etc. are located. Logically we must GIVE PERMISSIONS to the user "userapp" in this folder, or he will not be able to access this information. We can do it from the GUI by editing the user's privileges.
- Comment 4: In the "ports" section we define the ports for the application to communicate with the system. The syntax is the same as in the previous point, to the left of ":" is the port that we really want to use and to the right is the port that the application uses internally. In this case we have defined the same access port that the application uses internally. If we wanted to change it, for example, to port 8888 we would change the one on the left and it would look like this 8888: 8096
- At this time it is good practice to save the text file with the docker stack and keep it for future reference.
8. Deploy the Docker stack.
- In the OMV GUI in the <<OMV-Extras>> section we go to the "Docker" tab and click on the "Open Portainer" tab.
- If it is the first time we establish a password for "admin" and enter.
- Click on the whale icon, then on the left menu click on "stacks", then click on the top button "+ Add stack".
- We copy the custom stack in the window and above we fill the "name" field by typing "jellyfin". We scroll down the window and look for the "Deploy the stack" button. We press and wait for the stack to be implemented.
- When the process is finished, we can go to a browser and access the application by typing the IP of our server followed by ":" and the access port defined in the previous point. For example if the IP of our server was 192.168.1.100 we would write 192.168.1.100:8096
9. Modification of the stack.
- We can modify the stack parameters at any time. To do this, click on the name of the stack and then on the "Editor" button at the top.
- We access the current stack and we can change some parameter and update it by clicking on the "Update the stack" button at the bottom.
- If we want to delete the application configuration and start from scratch we can do so by previously deleting the /SSD/config/Jellyfin folder. Stop the container first.
I hope it is useful !!