Skip to content

Commit

Permalink
dockerplug add network param
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Apr 22, 2024
1 parent 558458b commit 57e4a3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/docker-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -140,6 +141,8 @@ if (!keepEntrypoint) {
createOptions.WorkingDir = path.dirname(ENTRYPOINT_PATH)
}

if(network) createOptions.HostConfig['NetworkMode'] = network


// ----------------RUNNING CONTAINER -------- //

Expand Down
1 change: 1 addition & 0 deletions sample_conf/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 57e4a3e

Please sign in to comment.