Plugin Docker

  • 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 :


    Code
    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.


    Code
    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)


    Code
    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 :

    Code
    docker start jeedom-mysql ; docker start jeedom-data ; docker start jeedom-web ;


    To stop Jeedom :

    Code
    docker stop jeedom-mysql ; docker stop jeedom-data ; docker stop jeedom-web ;
  • If I 've createe a plugin successful for one docker, with the possibilty to activate the container as a service, it would be esay to clone it for each docker image you want ...
    I've got still some work to do ...

  • docker seems to be working correctly but since install i get this error when accessing Network / Interfaces


    Device 'vethac76f2f' not supported


    Code
    Error #6003:
    exception 'OMVException' with message 'Device 'vethac76f2f' not supported' in /usr/share/openmediavault/engined/rpc/network.inc:254
    Stack trace:
    #0 [internal function]: OMVRpcServiceNetwork->enumerateDevicesList(Array, Array)
    #1 /usr/share/php/openmediavault/rpcservice.inc(125): call_user_func_array(Array, Array)
    #2 /usr/share/php/openmediavault/rpc.inc(79): OMVRpcServiceAbstract->callMethod('enumerateDevice...', Array, Array)
    #3 /usr/sbin/omv-engined(500): OMVRpc::exec('Network', 'enumerateDevice...', Array, Array, 1)
    #4 {main}
  • This is a "bug" in openmediavault. Docker creates a virtual network device called docker0, and for each container, a virtual device with the prefix vethXXXXX. OMV tries to validate the devices against known regex patterns, fails, and then throws an error. Best I can tell, it doesn't cause any issues.

  • The Docker UI is accessible through /dockerui in the browser without providing any credentials. Is that intended? I think that should rather be fixed as you can start/stop containers from the ui. Should be a quite serious security issue.

  • 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 :

    Code
    apt-get install apache2-utils
     htpasswd -c /etc/nginx/htpasswd admin


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

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



    Reload Nginx configuration :

    Code
    service nginx reload
  • Thanks for your work so far. I am not using this in production, so it is not a big deal for me right now. I just wanted to give you some feedback. :)


    Tommorrow I am on holidays for a few weeks, so I do not have the time for a closer look at the moment.

  • @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: https://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!

  • 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...


    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.

    • Offizieller Beitrag

    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?

  • 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.


  • I'll wait for some more input on this.


    - 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.


    - 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...


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


    Added.


    - 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...


    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...


    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...


    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.

Jetzt mitmachen!

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