[How to] Docker in OMV

    • Offizieller Beitrag

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________

    THIS GUIDE IS NOW ON THE OMV-EXTRAS WIKI.

    omv6:docker_in_omv [omv-extras.org]

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________



    This guide establishes a method to successfully install a docker application on OMV.


    _______________________________________________

    Introduction and basic concepts

    Instructions for preparing and installing docker

    Example of installing an application (Jellyfin)

    _______________________________________________





    Introduction and basic concepts


    Docker is a technology that enables the creation and use of Linux containers. A container is a closed environment where one or more applications and their dependencies are installed, grouped and isolated from each other, running on the same operating system kernel.


    Docker allows you to install, uninstall, modify, update applications as many times as you want without causing damage to the system.


    Starting from a system with OMV installed and with a file system with shared folders, to use Docker we need::

    • A SPACE in our file system to store the containers. The recommendation for this purpose is to dedicate an SSD disk, independent of the operating system, with EXT4 format, of at least 60GB. This approach provides application speed, avoids docker incompatibilities with special file systems, and makes applications completely independent of disk from the operating system. PROGRAM FILES and CONFIGURATION FILES will be stored in this space:
      • PROGRAM FILES:
        • They are expendable files.
        • They will be stored in the docker folder of the SSD drive.
        • Docker takes care of downloading these files from the internet and configuring them automatically.
        • Docker containers are updated by downloading the latest version of these files and replacing the old one. There are some exceptions, check the documentation for each container you install to find out how it works.
      • CONFIGURATION FILES:
        • They are irreplaceable files.
        • They will be stored in the appdata folder of the SSD drive.
        • They are created, modified and customized during the operation of the application with passwords, personal settings, databases, etc. depending on the use case.
        • We'll also use the compose folder to store docker-compose's composition stacks.
        • We must keep them if we want to keep the application in the same state or restore it after a reinstallation of OMV. It is a good idea to make regular backup copies of these two folders.
    • A USER who will be in charge of executing the container.
      • Docker applications execute the actions on the system from the container by means of a user. The permissions that we grant to this user will be the permissions that the container has. This will be the control mechanism to prevent the application from doing something on our system that we don't want it to do.
      • For security, it is convenient to create a user and grant only the necessary permissions for the application to work. In this guide this user is called appuser.
      • The containers should write/read in the docker and appdata folders. The way to give permissions to the container is to give them to the user who runs it. Therefore, we need to give appuser write permissions on these folders. Also, if we want the app to use data from our shared folders, appuser must have access to those folders as well.
      • For simplicity this guide uses a single user for all docker containers, appuser. Normally this will suffice. If you need to further adjust the security you can create a user for each container and further adjust the permissions.
    • A FILE SYSTEM where the data to be used by the application that we are installing is stored.
      • For simplicity, in this guide we limit ourselves to a single shared folder called DATA. You will probably have called it something else, name it your real folder instead of DATA.
      • These folders will store the data used by each application. In the case of Jellyfin, for example, we are referring to the movies, photos, etc. Which could be in DATA/media/films DATA/media/photos ...
      • The file system used to store this data is irrelevant. We just need OMV to recognize it and be able to create a shared folder in it and grant the necessary permissions to the user appuser.

    ;)

    forward to Instructions for preparing and installing docker

    forward to Example of installing an application (Jellyfin)

  • Agricola

    Hat das Thema freigeschaltet.
    • Offizieller Beitrag

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________

    THIS GUIDE IS NOW ON THE OMV-EXTRAS WIKI.

    omv6:docker_in_omv [omv-extras.org]

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________


    Instructions for preparing and installing docker


    1. Previous steps.

    • Install a dedicated drive (preferably SSD) in the server, format to EXT4 and mount to the file system.
    • Install openmediavault-omvextrasorg.


    2. Create symlinks /SSD and /DATA

    • Creating symlinks will avoid using long paths and will make it easier to replace disks by avoiding redoing all the containers. The use of symlinks is not mandatory, the objective is ease of use. If you prefer to use complete paths you can skip this point.
    • Install openmediavault-symlinks.
      • In the OMV GUI go to System>Plugins> find and select the plugin, then click Install on the top menu.
    • Create symlink /SSD pointing to the dedicated drive.
      • In the OMV GUI go to Storage>File Systems> open the Mount Point column (box icon on the top right) and press the button to copy the SSD disk mount point to the clipboard.
      • Go to Services>Symlinks> and click on +Create.
        • In the Source field, copy the SSD disk mounting path from the clipboard (or find the path in the tree).It should look something like /srv/dev-disk-by-uuid-385245af-f180-4977-acg5-5847f908e48g/
        • In the Destination field type /SSD
        • Press the lower Save button.
    • Create symlink /DATA pointing to userdata folder.
      • Following the same procedure, now create the symlink /DATA (use your actual folder name). Find the mount path of your data folder in Storage>Shared Folders> open the Absolute Path column and copy your folder path to clipboard by pressing the button.
      • Go to Services>Symlinks> and click on +Create.
        • In the Source field copy from the clipboard the mount path of the data folder (or find the folder in the tree).
        • In the Destination field write /DATA (use the name of your actual folder)
        • Press the lower Save button.


    3. Create folders for Docker files.

    • Create docker, appdata and compose shared folders on the dedicated disk. SSD or the one you have chosen.
      • Go to the OMV GUI -> Storage>Shared Folders Click on +Create In the Name field write docker. In the File system field select the SSD disk. Press Save.
      • Repeat the procedure for the appdata and compose folders.


    4. Install Docker and openmediavault-compose plugin.

    • In the OMV GUI, go to the System>omv-extras>Docker> and in the Docker storage field replace the value with the path of the docker folder created earlier, and press the Save button.
      • Warning: A symlink like /SSD/docker may not work here, it is preferable to use the full path. Example: /srv/dev-disk-by-uuid-861acf8c-761a-4b60-9123-3aa98d445f72/docker You can copy the path as in point 2 and add /docker at the end
      • Warning: Once the route has been entered, press the lower Savebutton. Otherwise the changes will not be saved and if you continue, docker will be installed in the default path /var/lib/docker, that is, on the system disk, which is what we want to avoid.
    • Install Docker: In the bottom menu, click the Save button. Then click the Install button.
      • Now in the Status field the message should appear: Installed and running
    • Install openmediavault-compose. (In the OMV GUI go to System>Plugins> find and select the plugin, then click Install  on the top menu.
      • Warning: If you install openmediavault-compose before changing the docker installation path, docker will be installed to the default path /var/lib/docker.
    • In the OMV GUI, go to Services>Compose>Settings and select the compose folder to store the yaml composition files. Press Save.

    5. Create the user "appuser".

    • In the OMV GUI go to Users>Users> click on the +Create button, define appuser name and assign password, in the groups field we add it to the users group. Click on Save.
    • Open the UID and GID columns and make a note of the values that the appuser user has. Example UID=1002 GID=100 If you already had one user, appuser UID will be 1001. If you had 2 users, appuser UID will be 1002, etc. This may vary on your system.


    back to Instroduction and basic concepts

    forward to Example of installing an application (Jellyfin)

    • Offizieller Beitrag

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________

    THIS GUIDE IS NOW ON THE OMV-EXTRAS WIKI.

    omv6:docker_in_omv [omv-extras.org]

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________

    Example of installing an application (Jellyfin):


    6. Choose a stack

    • On the dockerhub there are thousands of containers ready to configure. Try to choose containers from reputable publishers (linuxserver is very popular) or with many downloads and current ones. Check that the container is compatible with your server's architecture x86-64 arm64... When choosing one read the publisher's recommendations before installing it.
    • As an example we are going to install Jellyfin. Many results appear in the search engine, we chose the one for linuxserver see here https://hub.docker.com/r/linuxserver/jellyfin
    • We fetch 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's always a good idea to read the editor's comments to familiarize yourself with the options and to check that the container is valid for your architecture (x86, arm ...).
    • We customize our stack to fit our system. In this example, we remove all the optional lines and keep the essentials.
    • Let's assume as an example that inside /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 of this guide and adjust the correct values.
    • Comment 2: Adjust it to your location. You can see it by typing cat /etc/timezone in a terminal.
    • Comment 3: In the volumes section we map folders from the container to the host. This means that when the container writes to an internal folder, it will actually be writing to the folder we want outside the container. The syntax means that to the left of the ":" we define the actual path of the folder in our file system and to the right will be the equivalent path within the container.
      • So in the first line we tell the app that the config files are written to and read from our SSD in the appdata folder plus another subfolder called Jellyfin. It is not necessary to create the Jellyfin folder beforehand, docker can create up to one level of subfolders when the container is started.
      • In the second line we tell the application where the data to use is, movies, etc. The container will access our /DATA/media shared folder and mount it inside the container by naming it /media.
        • For this to work we must GIVE PERMISSIONS to the userapp on our /DATA/media shared folder. Otherwise the container (using the appuser permissions) will not be able to access this folder and the application will not start, it will show an error. We can give appuser permissions from the GUI by editing the user's privileges.
        • Note: In Jellyfin it is enough to map the DATA/media folder. Within Jellyfin we can configure the libraries of movies, music... by choosing the folders /media/films or /media/music...
    • 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 ":" we define the port of our nas that we want to use to access the application; on the right we define the port that the application uses internally.
      • Docker will communicate both ports. In this case we decided to change the real port to 8888, so we change the one on the left and keep the one used internally by the 8096 container.
    • It's a good idea to keep this text file with the docker stack for future reference or reinstallation. If we have this file and the appdata folder, reinstalling the application on another system takes two minutes.


    8. Deploy the Docker stack and access the application

    • In the OMV GUI, go to Services>Compose>Files and click on the +Create button. Copy in the File box the contents of the text file that we have created in point 7. In the Name field write the name of the container, in this case Jellyfin. Click the Save button and apply the changes.
      • Note: If you need to set environment variables you can do so in the lower Environment box.
    • Select (yellow) the created row corresponding to your container and press the Check button.
      • If there are no errors your stack can be executed. Otherwise you should review the values entered.
    • Press the Up button.
      • This will download the container image and install it.
      • At this point you should be able to access your application by typing the IP of our server followed by ":" and the access port defined in the previous point. In this case, if the IP of our server were 192.168.1.100 we would write http://192.168.1.100:8888 to access Jellyfin.


    9. Stack Modification.

    • To modify parameters in a stack:
      • In the OMV GUI go to Services>Compose>Files, select the container row and press the Down button. This will stop the container.
      • Press the Edit button. Modify the desired parameters in the File box and press Save.
      • Select the container row again and press the Up button. The container will now be running with the modified parameters.
    • To restore the container to its initial state, this will remove any configuration we have made to the container.
      • Stop the execution of the container. Down button.
      • Delete the config folder corresponding to the container. (in the example /SSD/appdata/Jellyfin)
      • Start the container. Up button.


    10. More information.

    • openmediavult-compose
    • Ports available to configure in the applications, see here
    • How to backup Portainer see here
    • How to move the /var/lib/docker folder to another disk if it is already up and running see here
    • How to generate a docker-compose yaml file from an already deployed container see here



    back to Introduction and basic concepts

    back to Instructions for preparing and installing docker

    • Offizieller Beitrag

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________

    THIS GUIDE IS NOW ON THE OMV-EXTRAS WIKI.

    omv6:docker_in_omv [omv-extras.org]

    ______________________________________________________________________________________________________________

    ______________________________________________________________________________________________________________


    Container management with Portainer


    • This guide has described how to use docker in Openmediavault using the openmediavault-compose plugin.
    • At any time you can manage these containers from Portainer without doing anything more than installing Portainer. The only thing to keep in mind is that stacks created using openmediavault-compose cannot be edited in Portainer and vice versa.
    • If you prefer to use Portainer instead of openmediavault-compose do the following:


    1. Install Portainer

    • In the OMV GUI go to System>omv-extras>Portainer> press the install button in the bottom menu.
      • The Status field will now show how long Portainer has been running


    2. Deploy the Docker stack and access the application

    • In the OMV GUI go to System>omv-extras>Portainer> and click on Open web. If it is the first time we set 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
    • Copy the custom stack into the window and fill in the name field above by typing jellyfin (or the name of your application). Scroll the window down and click the Deploy the stack button. Wait for the stack to be deployed.
    • 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 point seven of this guide. For example if the IP of our server was 192.168.1.100 we would write http://192.168.1.100:8888


    3. Stack Modification.

    • To modify parameters in a stack:
      • Click on the stack name to modify.
      • Click on the Editor button at the top.
      • Modify stack parameters
      • Click the Update the stack button at the bottom.
    • Restore the container to its initial state, this will delete any configuration that we have made in the container.
      • Stop the execution of the container.
      • Delete the config folder corresponding to the container. (in the example /SSD/config/Jellyfin)
      • Start the container.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!