Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • --user Inside the container the Agent is operated for the user account jobscheduler. In order to access e.g. log files created by the Agent that are mounted to the Docker host it is recommended that you map the account that is starting the container to the jobscheduler account inside the container. The --user option accepts the user ID and group ID of the account that will be mapped. The above example makes use of the current user.
  • --network The above example makes use of a Docker network - created e.g. with the command docker network create js7 - to allow network sharing between containers. Consider that any inside ports used by Docker containers are visible within a Docker network. Therefore an Agent running for the inside port 4445 is accessible with the container's hostname and the same port within the Docker network.
  • --publish The Agent is prepared to listen to the HTTP port 4445. An outside port of the Docker host can be mapped to the Agent's inside HTTP port. This is not required for use with a Docker network, see --network, however, it will allow direct access to the Agent from the Docker host by its outside port .
  • --env=RUN_JS_JAVA_OPTIONS This allows to inject any Java options to the Agent's container. Preferably this is used to specify memory requirements of an Agent, e.g. with -Xmx256m.
  • --mount The following volume mounts are suggested:
    • var: This folder works as an entry point to the following sub-folders:
      • config: The configuration folder allows specification of individual settings for Agent operation, see the chapters below and the JS7 - Agent Configuration Items article. Default settings are available on initial operation.
      • logs: In order to have Agent log files persisted they have to be written to a volume that is mounted for the container. Feel free to adjust the volume name from the src attribute, however, the value of the dst attribute should not be changed as it reflects the directory hierarchy inside the container.
      • state: The Agent requires a directory for journal information that should be persisted. The journal is required to restore the state of orders when restarting the Agent.
    • Docker offers a number of ways how to mount volumes to containers that include e.g. creating a local folder and mapping the folder to a volume before executing the above docker run command.:

      Code Block
      languagebash
      titleExample how to create Docker volumes
      linenumberstrue
      # example to map volumes to directories on the Docker host prior to running the Agent container
      mkdir -p /home/sos/js7/js7-agent-primary/var
      docker volume create --driver local --opt o=bind --opt type=none --opt device="/home/sos/js7/js7-agent-primary/var" js7-agent-primary-var
  • sosberlin/js7:agent-2-0-0-SNAPSHOT: The name of the base image is the same that was previously used with the docker pull command. Alternatively this could be sosberlin/js7:agent-2-0-0-SNAPSHOT-plus for use of a "plus" image.

Further Resources

Running the Agent Container from a "plus" Image

...

...

PowerShell Profile

By default the "plus" Agent image creates the following PowerShell profile inside the container with the path /home/jobscheduler/.config/powershell/Microsoft.PowerShell_profile.ps1:

Code Block
languagepowershell
titleDefault PowerShell profile
linenumberstrue
$PSReadLineOptions = @{Colors=@{"Default"="Blue"; "Command"="Blue"; "Parameter"="Blue"; "Variable"="Blue"; "Number"="Blue"; "Member"="Blue"; "Operator"="Blue"}}
Set-PSReadlineOption -Colors $PSReadLineOptions.Colors

if ( Test-Path $env:JS7_AGENT_CONFIG_DIR/Microsoft.PowerShell_profile.ps1 -PathType Leaf -ErrorAction SilentlyContinue )
{
  .  $env:JS7_AGENT_CONFIG_DIR/Microsoft.PowerShell_profile.ps1
}

Explanation:

  • Readline options specify colors used for better visibility of the prompt when directly invoking PowerShell inside a container.
  • A profile assumed inside the Agent's config directory is executed if applicable.

Running PowerShell Commands inside the Container

To try out a "plus" Agent container you can use the following sequence of commands:

Code Block
languagepowershell
titleExecute PowerShell cmdlets in a "plus" container
linenumberstrue
# From the Docker host invoke a PowerShell session within the Agent container
docker exec -ti js7-agent-primary pwsh

# Receive a PowerShell prompt like this
#   PowerShell 7.1.3
#   Copyright (c) Microsoft Corporation.
#   https://aka.ms/powershell
#   Type 'help' to get help.
#   PS />

# Load the JS7 PowerShell module
PS />Import-Module JS7

# Connect to the JOC Cockpit container specifying account ("root") and password ("root") with the JOC Cockpit URL like this:
PS />Connect-JS7 -Url http://root:root@js7-joc-primary:4446 -Id jobscheduler

# An alternative way is to create a credential object like this
#   PS />$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "root", ( "root" | ConvertTo-SecureString -AsPlainText -Force) )
#   PS />Connect-JS7 -Url http://js7-joc-primary:4446 -Id jobscheduler -Credentials $credentials

# The recommended way is to login to the JOC Cockpit REST API by use of a certificate should JOC Cockpit be configured for HTTPS and certificate based authentication
#   PS />$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "certs", ( "jobscheduler" | ConvertTo-SecureString -AsPlainText -Force) )
#   PS />Connect-JS7 -Url https://js7-joc-primary:4443 -id jobscheduler -KeyStorePath /var/sos-berlin.com/js7/agent/var_4445/config/private/https-keystore.p12 -KeyStoreCredentials $credentials -RootCertificatePath /var/sos-berlin.com/js7/agent/var_4445/config/private/https-truststore.p12 -RootCertificateCredentials $credentials

# Display Controller status
PS />Get-JS7ControllerStatus -display

# The command should return the following output:
#   ________________________________________________________________________
#   ....... Controller ID: jobscheduler
#   ............. version: 2.0.0-alpha.20210511
#   ................. URL: http://controller-2-0-primary:4446
#   ................ role: PRIMARY
#   ............... title: PRIMARY CONTROLLER
#   ....... running since: 04/30/2021 15:00:34
#   ...... security level: MEDIUM
#   ..... cluster coupled: True
#   .. cluster node state: active
#   .... component status: operational
#   ... connection status: established
#   ________________________________________________________________________

Running PowerShell Jobs

To execute PowerShell code from a job running inside a "plus" Agent container you can use the following sequence of commands:

Code Block
languagepowershell
titleExecute PowerShell cmdlets in a "plus" container
linenumberstrue
pwsh -NoLogo -NonInteractive -Command '& {
    Import-Module JS7
    Connect-JS7 -Url http://root:root@js7-joc-primary:4446 -Id jobscheduler

    Get-JS7ControllerStatus -display
}'

...

Configure the Agent

Note that it is not necessary to configure the Agent - it runs out-of-the-box. The default configuration specifies that

...