Plugin Docker

    • OMV 1.0

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • I'm trying to create plugin for different docker container ... but if you want to test it, you can use terminal and use docker !

      - docker run : allow to create a container from an image, if the image is not already download, docker run download it, then start it automatically.
      - once the container created, you can start and stop it with docker start or docket start. You can also use dockerUI to start or stop.

      Here an example to install different containers for Jeedom an Home Automation Service :

      Source Code

      1. docker run -d --name jeedom-mysql -e MYSQL_ROOT_PASSWORD=set_a_password -v /media/RAID_volume_like_f65f6a6b183e31b/Jeedom-mysql:/var/lib/mysql mysql:5.6.21

      Docker will download the image with a database MySQL needed by Jeedom, then create a container with a password set by you and a folder mapping between /media/RAID_volume_like_f65f6a6b183e31b/ (your NAS volume) and the data directory of MySQL var/lib/mysql.

      Source Code

      1. docker run --name jeedom-data -v /media/RAID_volume_like_f65f6a6b183e31b/Jeedom-data:/usr/share/nginx/www/jeedom --link jeedom-mysql:mysql cquad/jeedom-data

      Here, Dokcer download an image, then create a container to manage data of Jeedom (webapp)

      Source Code

      1. docker run -d --name jeedom-web --volumes-from jeedom-data --link jeedom-mysql:mysql -p 80:80 -p 8070:8070 cquad/jeedom-web

      Now a last container to have the servie truned on with dependancy to the 2 previous container with a mapping of port, it's possible to map USB device like file/folder mapping.

      That's all, you can after that create an init file with command line like :

      To start Jeedom :

      Source Code

      1. docker start jeedom-mysql ; docker start jeedom-data ; docker start jeedom-web ;

      To stop Jeedom :

      Source Code

      1. docker stop jeedom-mysql ; docker stop jeedom-data ; docker stop jeedom-web ;
    • docker seems to be working correctly but since install i get this error when accessing Network / Interfaces

      Device 'vethac76f2f' not supported

      Source Code

      1. Error #6003:
      2. exception 'OMVException' with message 'Device 'vethac76f2f' not supported' in /usr/share/openmediavault/engined/rpc/network.inc:254
      3. Stack trace:
      4. #0 [internal function]: OMVRpcServiceNetwork->enumerateDevicesList(Array, Array)
      5. #1 /usr/share/php/openmediavault/rpcservice.inc(125): call_user_func_array(Array, Array)
      6. #2 /usr/share/php/openmediavault/rpc.inc(79): OMVRpcServiceAbstract->callMethod('enumerateDevice...', Array, Array)
      7. #3 /usr/sbin/omv-engined(500): OMVRpc::exec('Network', 'enumerateDevice...', Array, Array, 1)
      8. #4 {main}
      HP GEN8 Micro Server 10GB Ram + 4xWD Red 2TB
    • In fact, I'm thinking about something ...

      I'll separate dopcker plugin and dockerui to another plugin ...
      Docker will be dependancy of dockerui plugin. And i would be able to have a configuration page (expose port, expose directory name of the container, login/password for apache authentication and a checkbox to run/stop a service launching the docker container and may be another checkbox for always-restart option when OMV started. It would be better and all other plugins by docker should be use the same template of pages/plugin ...

      Just one thing, for now I've no idea to do that ... (the plugin part)
    • @inta : To add login/password on dockerui you can do someting like that :

      Add a htpasswd file with the user admin and the password you want :

      Source Code

      1. apt-get install apache2-utils
      2. htpasswd -c /etc/nginx/htpasswd admin

      Then add few lines in the dockerui config file like that :

      Source Code

      1. nano /etc/nginx/openmediavault-webgui.d/openmediavault-docker-site.conf

      Source Code

      1. location /dockerui/ { proxy_pass http://localhost:9200/;
      2. #http 1.1 support...
      3. proxy_http_version 1.1;
      4. proxy_set_header Connection "";
      5. proxy_set_header Host :9200; auth_basic "Login";
      6. auth_basic_user_file /etc/nginx/htpasswd;
      7. }
      8. location /dockerapi/ {
      9. proxy_pass http://localhost:9200;
      10. proxy_set_header Host :9200;
      11. proxy_redirect default;
      12. #http 1.1 support...
      13. proxy_http_version 1.1;
      14. proxy_set_header Connection "";
      15. auth_basic "Login";
      16. auth_basic_user_file /etc/nginx/htpasswd;
      Display All

      Reload Nginx configuration :

      Source Code

      1. service nginx reload
    • @slobberbone I've built my own docker plugin and now I found out that you already had done this already :) My "version" works by using the docker commandline and displaying various data in the "standard" OMV (ExtJS) layout. Would you be able to have a look at this to see if it's something that could be used in your plugin? Available features so far:
      • Pull images / Delete images
      • List images in grid
      • "Run" images with various parameters (port mappings, environment variables, bind mounts etc)
      • List containers in grid
      • Start/Stop/Restart/Delete containers
      • Get detailed info on container
      On the todo list is "copying" an existing container (variables) into a new container and also run a command inside a running container. You can find all the code on my GitHub: github.com/nicjo814/openmediavault-docker and it builds with fakeroot debian/rules clean binary to give you a .deb package. Please let me know what you think.
    • Nicjo, may I ask how much time it took you to build this version of your docker plugin?

      Greetings
      David
      "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"

      Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.


      Upload Logfile via WebGUI/CLI
      #openmediavault on freenode IRC | German & English | GMT+1
      Absolutely no Support via PM!

      I host parts of the omv-extras.org Repository, the OpenMediaVault Live Demo and the pre-built PXE Images. If you want you can take part and help covering the costs by having a look at my profile page.
    • davidh2k wrote:

      Nicjo, may I ask how much time it took you to build this version of your docker plugin?

      Greetings
      David

      I've been working on it on and off for some time now, but effectively I think a couple of evenings plus one day or so. I'm no fast coder since I always change my mind on how I want things to look and behave :) I think I've done at least three different implementations of the "run image" dialog before finding one that I'm happy with...

      WastlJ wrote:

      Excellent work Nicjo! - Maybe you can merge the two plugins to one?

      Thanks! I was thinking the same thing. Until then I'll read up on how to integrate with Docker through it's API to see if that can speed up the listings of Images/Containers. Then it would be nice with an integration directly to the Docker Hub API...
    • I've changed some parts of the code to use API communication instead of cli (to improve speed in Image/container) listings. For this purpose I've introduced a setting that allows you to change which port the plugin should use for communication with the API. However this requires a change to the /etc/defaults/docker file to add a row like DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock" to make the API listen to a specific port. I would really appreciate if someone could help me out with how to make this change in the postinst script as well as remove it in the postrm script :)

      EDIT: Actually I think that the postinst script should search for existing DOCKER_OPTS config and append either both -H options or just one if the unix socket is already listed. The postrm script should probably not do anything... This could probably be achieved by some sed/awk magic, but that's above my current skill level :)

      EDIT: The copy functionality is now completed.

      The post was edited 2 times, last by nicjo814 ().

    • A couple of notes:

      - DOCKER_OPTS: I use custom docker options by setting up custom location for containers instead of /var/lib/docker. So be careful so try to append and not replace.
      In case, JUST IN CASE you want to leave that option to setup as shared folder is

      DOCKER_OPTS="-g /media/46e48dd3-8f8a-42f4-a503-0084368be19e/docker"

      I haven't evaluate this in terms of how to move the containers across, i know there is a import/export command. But it can really complicate things for users having existing containers. @shadowzero was playing with this, i don't know his conclusions.

      - Docker also can search from the CLI, is very basic but maybe it can be implemented. I don't know how to cache all the repo database so people can use autocomplete or a dropdown menu to execute pull.

      - Maybe have a tab with the README of the image from the hub. So people have a notion of the settings required in the parameters section.

      - Is missing the option of naming the running container, my guess this would be useful for copy function.
      - I am not a programmer, but can autocomplete as typing be used for filling the host path or maybe use shared folders? I've seen this autocomplete for paths, in sonarr (C#) and syncthing (Go language)

      @nicjo814 be prepared this plugin will bring a huge amounts of new users to OMV.

      And lastly: Have you done any improvements in the OMV front end in your personal OMV server that you think is worth to take in consideration?
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server
    • My thought is to not enable the plugin after post install. Rather add the option to set the shared folder to use instead of the default /var/lib/docker. Take a look at the virtualbox plugin for example. Set the shared folder 1st to use for docker then enable it. Set the folder path in /etc/default/docker and the /etc/init.d/docker to point to the shared folder. I'll go into more detail tomorrow. I have a bad headache tonight and it is hard to concentrate.
      ShadowZero -- OMV Fan since 0.3
    • subzero79 wrote:

      A couple of notes:

      - DOCKER_OPTS: I use custom docker options by setting up custom location for containers instead of /var/lib/docker. So be careful so try to append and not replace.
      In case, JUST IN CASE you want to leave that option to setup as shared folder is

      DOCKER_OPTS="-g /media/46e48dd3-8f8a-42f4-a503-0084368be19e/docker"

      I haven't evaluate this in terms of how to move the containers across, i know there is a import/export command. But it can really complicate things for users having existing containers. @shadowzero was playing with this, i don't know his conclusions.

      I'll wait for some more input on this.

      subzero79 wrote:

      - Docker also can search from the CLI, is very basic but maybe it can be implemented. I don't know how to cache all the repo database so people can use autocomplete or a dropdown menu to execute pull.

      I found an example of how this could be implemented that I' might look into a bit more. Simple search should be easy, but it's the autocomplete that can be tricky.

      subzero79 wrote:

      - Maybe have a tab with the README of the image from the hub. So people have a notion of the settings required in the parameters section.

      Done, even though it's far from an optimal solution...

      subzero79 wrote:

      - Is missing the option of naming the running container, my guess this would be useful for copy function.

      Added.

      subzero79 wrote:

      - I am not a programmer, but can autocomplete as typing be used for filling the host path or maybe use shared folders? I've seen this autocomplete for paths, in sonarr (C#) and syncthing (Go language)

      Maybe using a combobox with a change listener that executes an RPC call that runs "find" in the current dir could be used...

      subzero79 wrote:

      @nicjo814 be prepared this plugin will bring a huge amounts of new users to OMV.

      Hmmm... I won't have time to maintain this that well I'm afraid. Could we maybe move things over to omvextras @ryecoaaron? I'm still not very good with Github...

      subzero79 wrote:

      And lastly: Have you done any improvements in the OMV front end in your personal OMV server that you think is worth to take in consideration?

      Nope, haven't had the opportunity to do any coding since the ZFS plugin...

      shadowzero wrote:

      My thought is to not enable the plugin after post install. Rather add the option to set the shared folder to use instead of the default /var/lib/docker. Take a look at the virtualbox plugin for example. Set the shared folder 1st to use for docker then enable it. Set the folder path in /etc/default/docker and the /etc/init.d/docker to point to the shared folder. I'll go into more detail tomorrow. I have a bad headache tonight and it is hard to concentrate.

      Sound interesting. Will have to look into this a bit more.