Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Start docker template via command line

Featured Replies

Is it possible to start a docker container based on an .xml template via the command line?

 

I'm aware of 'docker run <docker image> -v <volumes> etc...'

However, all of the these run arguments are stored in xml files in /boot/config/plugins/dockerMan/templates-user

 

I know the docker plugin uses these, but I only have ssh access when I'm away from my local network, so I have no GUI access to start them.

 

So basically i'm looking for something along the lines of: 'docker_plugin run <my-container-template.xml>'

Someone can correct me if I'm wrong.  But the Community Apps/DockerMan pages scrape the XML for the needed info to get the same "docker run" command. 

 

I keep a Simplenote sheet with all my run commands.

Community Apps/DockerMan pages scrape the XML for the needed info to get the same "docker run" command. 

Correct.  Shouldn't actually be that big a job to come up with script to do the same thing

You could probably come up with some XSL and plug it in here.

  • Author

Cool. I'll look into it and post back.  Just didn't want to re-invent the wheel if it was already done.

  • Author

Well, I made a bash script that parses xml template files and executes 'docker run -d' with the appropriate arguments populated from the template file.

 

The script takes one argument: The path to the .xml template file.

./RunDockerTemplate.sh <path_to_xml_template_file>

 

I've been running into problems with volume mappings that have spaces in their path (ie. /mnt/user/my media).

This is a known bug.  If any of you guys are bash scripting gurus, please feel free to fix my script!

 

Anyway - the point of this was to be able to edit docker containers without having to login to the GUI.  This is useful for me if I am away from my home network and only have SSH access.

 

Unzip the script by executing:

unzip RunDockerTemplate.zip

 

Hope it helps someone out!

 

RunDockerTemplate.zip

  • 2 years later...

Awesome script Skidelo, I've been looking for something like that.

 

I've updated the script. I found some problems, and have fixet some of them. Maybe the xml format or parse has changed.

 

Changes:

  • Fixed parsing of muliple volumes and ports (didn't 
  • Added quotes around volumes
  • Parse multiple files like with *.xml
  • Added dryrun and verbose flags

Current Problem: The xmlint xml-decoder does not parse xml-encoded strings like &#xF8;, so beware. For me the docker command failed, and I could manually add that docker.

 

Best Alex

 

RunDockerTemplate.zip

Edited by Alex R. Berg

  • 3 years later...

Ran across this thread.  My solution:  pass the path to the xml as the argument to the script.  Should work with absolutely any xml

#!/usr/bin/php
<?
$docroot = "/usr/local/emhttp";

require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";

$var = parse_ini_file('/var/local/emhttp/var.ini');
$cfg = parse_ini_file('/boot/config/docker.cfg');

$driver = DockerUtil::driver();
$custom = DockerUtil::custom();
$subnet = DockerUtil::network($custom);

$opts = xmlToCommand($argv[1]);
$cmd = str_replace("create ","run -d ",$opts[0]);

passthru($cmd);
?>

 

I was reading this old article when you replied to it @Squid!

 

I tried your above script with both the script and my xml in /tmp, but got an error

root@TheDeathStar:/tmp# ./runxml.sh my-gluetun.xml 

Warning: parse_ini_file($docroot/state/var.ini): failed to open stream: No such file or directory in /tmp/runxml.sh on line 7
docker: invalid reference format.
See 'docker run --help'.

The path/file set in $var exists.

root@TheDeathStar:/tmp# ls -lartih /usr/local/emhttp/state/var.ini
3243287 -rw-rw-rw- 1 root root 3.3K Aug  7 03:21 /usr/local/emhttp/state/var.ini

as does that for $cfg

root@TheDeathStar:/tmp# ls -lartih /boot/config/docker.cfg
11063 -rw------- 1 root root 350 Jul 30 16:14 /boot/config/docker.cfg

Can you offer any pointers as to what I should follow up on to resolve?

Adjusted the path on my post.  It was a result of my dev environment

 

Also, the path you're passing thru to the command should be /boot/config/plugins/dockerMan/templates-user/my-gluetun.xml (which is presumably where its located and not in the current directory (/tmp)

 

  • 3 weeks later...

Thanks @Squid that works perfectly now, and much appreciated.

  • 2 months later...

After finding this thread (Thanks everyone!) I ended up having to make some modifications to run it on my server running the latest Unraid (6.9.2)

 

I updated all the xpath to be more modern/proper (eg. //Name -> /descendant::Name etc) as it was not working correctly with env vars anymore. I also changed a couple things I noticed were different like it always binding the TZ, adding HOST_OS and quoting using single not double quotes among a couple other things.

 

I thought I might as well share my work incase someone is looking for this kinda thing and doesn't have the know-how to update this script.  Also, a tip of how I managed this script, I used the user scripts plugin to put the script in for easy management, and then just run it from there (dry-run and verbose in this case):
 

sh /boot/config/plugins/user.scripts/scripts/runDockerTemplate/script -yv /boot/config/plugins/dockerMan/templates-user/my-xml-file.xml

 

RunDockerTemplate.zip

  • 1 year later...

I found this thread through a link in the Rebuild-DNDC package

It was using this script to convert the XML into a docker command to restart child containers linked to a parent container network.
It stopped working at some point, wasn't finding volumes etc... I believe the XML format must have changed in the last year

I've written a quick and dirty update to it which I thought I'd link here just in case anyone is still looking for this functionality


https://github.com/Phil-Barker/rebuild-dndc/blob/master/Rebuild-DNDC/ParseDockerTemplate.sh

Edited by PhilBarker
wrong URL

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.