From 57e4a3edc278d92bfad3172901d91ebd2029e439 Mon Sep 17 00:00:00 2001 From: mikeTWC1984 Date: Sun, 21 Apr 2024 22:59:04 -0400 Subject: [PATCH] dockerplug add network param --- bin/docker-plugin.js | 3 +++ sample_conf/setup.json | 1 + 2 files changed, 4 insertions(+) diff --git a/bin/docker-plugin.js b/bin/docker-plugin.js index 7b6b207..18e2e2d 100644 --- a/bin/docker-plugin.js +++ b/bin/docker-plugin.js @@ -62,6 +62,7 @@ const docker = new Docker(dockerOpts) const ENTRYPOINT_PATH = process.env['ENTRYPOINT_PATH'] || '/cronicle.sh' const cname = 'cronicle-' + (process.env['JOB_ID'] || process.pid) let imageName = process.env['IMAGE'] || 'alpine' +let network = process.env['NETWORK'] let script = process.env['SCRIPT'] ?? "#!/bin/sh\necho 'No script specified'" const autoPull = !!parseInt(process.env['PULL_IMAGE']) const autoRemove = !parseInt(process.env['KEEP_CONTAINER']) @@ -140,6 +141,8 @@ if (!keepEntrypoint) { createOptions.WorkingDir = path.dirname(ENTRYPOINT_PATH) } +if(network) createOptions.HostConfig['NetworkMode'] = network + // ----------------RUNNING CONTAINER -------- // diff --git a/sample_conf/setup.json b/sample_conf/setup.json index e286d10..f853da1 100644 --- a/sample_conf/setup.json +++ b/sample_conf/setup.json @@ -109,6 +109,7 @@ { "id":"command", "type":"text", "size":40, "title":"Command", "value": "" }, { "id":"script", "type":"textarea", "rows":10, "title":"Script", "value": "\n#!/bin/sh\n\necho \"Running Docker job on $HOSTNAME\"\n\ncat /etc/os-release\n\nls -lah chain_data || echo \"no chain data\"\n\n# If Docker Host is not specified, docker socket will be used\n# To access remote docker machine via ssh (on top of socket) specify DH as:\n# ssh://user[:password]@host[:port]\n# To specify ssh credentials you can also use SSH_PASSWORD/SSH_KEY env varaibles\n# To access remote docker instance with exposed http:\n# http://dockerhost:2375 (there is no auth options for that at this point)\n# To specify image registry credentials use DOCKER_USER, DOCKER_PASSWORD variables\n# All credential variables can be set via event/plugin secrets\n\n# This script will be used as an entrypoint on the container (mounted as /cronicle.sh by default).\n# To use original entrypoint check corresponding checkbox below,\n# and use command parameter above to pass argument to it\n# If this job is chained by other event, chain data will be mounted to the container\n# as chain_data file \n\n# In order to pass variables to container (other than JOB_ and ARG*) it should start with DOCKER_\n\n# If job is aborted \"docker stop\" is invoked (SIGTERM), docker will send SIGKILL after some time\n# Try to handle SIGTERM in your script for proper shutdown on abortion\n"}, { "id":"entrypoint_path", "type":"text", "size":40, "title":"Mount As", "value": "" }, + { "id":"network", "type":"text", "size":20, "title":"Network", "value": "" }, { "id":"keep_entrypoint", "type":"checkbox", "title":"Keep Original Entrypoint", "value": 0 }, { "id":"pull_image", "type":"checkbox", "title":"Pull Image", "value": 1 }, { "id":"keep_container", "type":"checkbox", "title":"Keep Container", "value": 0 },