Versions Compared

Key

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

...

Code Block
languagebash
titleRunning the JOC Cockpit Container for HTTP Connections
linenumberstrue
#!/bin/sh

docker run -dit --rm \
      --user="$(id -u $USER):$(id -g $USER)" \
      --hostname=js7-joc-primary \
      --network=js7 \
      --publish=17446:4446 \
      --env="RUN_JS_JAVA_OPTIONS=-Xmx256m" \
      --mountenv="type=volume,src=js7-jocRUN_JS_USER_ID=$(id -u $USER):$(id -g $USER)" \
      --mount="type=volume,src=js7-joc-primary-config,dst=/var/sos-berlin.com/js7/joc/resources/joc" \
      --mount="type=volume,src=js7-joc-primary-logs,dst=/var/log/sos-berlin.com/js7/joc" \
      --name js7-joc-primary \
      sosberlin/js7:joc-2-0-0-SNAPSHOT

Explanation:

  • ---user Inside the container the JOC Cockpit instance is operated for the user account jobscheduler. In order to access e.g. log files created by the JOC Cockpit instance 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. Note that any inside ports used by Docker containers are visible within a Docker network. Therefore a JOC Cockpit instance running for the inside port 4446 is accessible with the container's hostname and the same port within the Docker network.
  • --publish The JOC Cockpit is prepared to listen to the HTTP port 4446. An outside port of the Docker host can be mapped to the JOC Cockpit inside HTTP port. This is not required for use with a Docker network, see --network, however, it will allow direct access to the JOC Cockpit from the Docker host by its outside port .
  • 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. Note that any inside ports used by Docker containers are visible within a Docker network. Therefore a JOC Cockpit instance running for the inside port 4446 is accessible with the container's hostname and the same port within the Docker network.
  • --publish The JOC Cockpit is prepared to listen to the HTTP port 4446. An outside port of the Docker host can be mapped to the JOC Cockpit inside HTTP port. This is not required for use with a Docker network, see --network, however, it will allow direct access to the JOC Cockpit from the Docker host by its outside port .
  • --env=RUN_JS_JAVA_OPTIONS This allows to inject any Java options to the JOC Cockpit container. Preferably this is used to specify memory requirements of JOC Cockpit, e.g. with -Xmx256m.
  • --env=RUN_JS_USER_ID Inside the container the JOC Cockpit is operated for the user account jobscheduler. In order to access e.g. log files created by the JOC Cockpit 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 RUN_JS_USER_ID environment variable accepts the user ID and group ID of the account that will be mapped. The above example makes use of the current user--env=RUN_JS_JAVA_OPTIONS This allows to inject any Java options to the JOC Cockpit container. Preferably this is used to specify memory requirements of JOC Cockpit, e.g. with -Xmx256m.
  • --mount The following volume mounts are suggested:
    • config: The optional configuration folder allows to specify individual settings for JOC Cockpit operation, see below chapters and the JS7 - JOC Cockpit Configuration Items article. Without this folder the default settings are used.
    • logs: In order to have JOC Cockpit 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.
    • Docker offers a number of ways how to mount or to bind volumes to containers that include e.g. to create local directories and to bind them to volumes like this:

      Code Block
      languagebash
      titleExample how to create Docker volumes
      linenumberstrue
      # example to map volumes to directories on the Docker host prior to running the JOC Cockpit container
      mkdir -p /home/sos/js7/js7-joc-primary/config /home/sos/js7/js7-joc-primary/logs
      docker volume create --driver local --opt o=bind --opt type=none --opt device="/home/sos/js7/js7-joc-primary/config" js7-joc-primary-config
      docker volume create --driver local --opt o=bind --opt type=none --opt device="/home/sos/js7/js7-joc-primary/logs" js7-joc-primary-logs

      There are alternative ways how to achieve this. As a result you should have a access to the directories /var/sos-berlin.com/js7/joc/resources/joc and /var/log/sos-berlin.com/js7/joc inside the container and data in both locations should be persisted. If volumes are not created before running the container then they will be automatically mounted. However, you should have access to data in the volumes, e.g. by access to /var/lib/docker/volumes/js7-joc-primary-config etc.

...