docker plugin information

36 views
Skip to first unread message

Chris Grigor

unread,
Nov 30, 2021, 6:52:03 AM11/30/21
to rundeck-discuss
Hi all, 

I have recently installed the docker plugin from the gihub plugin pages. 
I was wondering how to grab the container id as a variable so that I can pass it between job steps?

I have several steps in my job, which are as follows

- (bash) STS AssumeRole
- (bash) code commit clone repo
- (bash) AWS ECR pull container image to node
- (docker plugin) 'run container'
- (docker plugin) kill container - this is the task I need the container id but how do I grab this?

The documentation on the github site have no examples so I'm not sure how to do this? Can anyone provide an example? 

Thanks in advance
Chris

rac...@rundeck.com

unread,
Nov 30, 2021, 8:31:19 AM11/30/21
to rundeck-discuss

Hi Chris,

I made an example that works in the following way: 1) from the docker ps command you will select the container id position in an option job (starting from 2, the first position it’s just the “CONTAINER ID” string). 2) The first step takes that and generates a ${data.container} data value. 3) You can use that data value ${data.container} in any workflow step.

I left the job definition example:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 030801bc-6933-472f-ae61-cae11121ca6e
  loglevel: INFO
  name: ContainerID
  nodeFilterEditable: false
  options:
  - name: position
    value: '2'
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - fileExtension: .sh
      interpreterArgsQuoted: false
      plugins:
        LogFilter:
        - config:
            invalidKeyPattern: \s|\$|\{|\}|\\
            logData: 'true'
            name: container
            regex: (.*)
          type: key-value-data
      script: docker ps | awk 'NR==@option.position@ {print $1}'
      scriptInterpreter: /bin/bash
    - configuration:
        container: ${data.container}
        debug: 'false'
      nodeStep: true
      type: docker-container-inspect-workflow-step
    keepgoing: false
    strategy: node-first
  uuid: 030801bc-6933-472f-ae61-cae11121ca6e

The example just shows the container status using the Docker plugin but you can use the data value on any Docker/non-Docker step.

Feel free to modify it :-)

Hope it helps!

Chris Grigor

unread,
Nov 30, 2021, 8:58:47 AM11/30/21
to rundeck-discuss
Thanks very much, I will try it out and post the results for others to share ;-)
Reply all
Reply to author
Forward
0 new messages