Run Custom Shell Scripts at Gateway Startup
When running the Container Gateway appliance, you can add custom shell scripts that execute as part of the Gateway start-up. This allows you to customize the image at run-time. (For example, you wish to generate another bundle using a different set of environment variables to create a JDBC connection to an Outh Toolkit database prior to installing the OTK.)
gateway93
When running the Container Gateway appliance, you can add custom shell scripts that execute as part of the Gateway start-up. This allows you to customize the image at run-time. (For example, you wish to generate another bundle using a different set of environment variables to create a JDBC connection to an Outh Toolkit database prior to installing the OTK.)
All scripts must complete successfully before the Container Gateway starts up.
The shell scripts run as a non-root user belonging to the root group. As a result, these scripts cannot perform actions that require root access.
Before you run custom scripts, you must make sure:
- The scripts have the.shsuffix.
- The scripts are POSIX-compatible.
This section describes how to:
Place the Scripts
To run custom scripts:
- Place the script file(s) into this directory within the Container Gateway image:/opt/docker/rc.d/
- Update your Dockerfile to something similar to the following:FROM original_image_nameUSER rootCOPY<folder_containing_scripts>"/opt/docker/rc.d/"RUN chmod -R 750 "/opt/docker/rc.d/"#Switch back to the ENTRYPOINT userID so the container does not run with the root userUSER ${ENTRYPOINT_UID}This retrieves the scripts from the specified source folder, copies it into the required folder, and then changes the permissions accordingly.
The shell scripts execute with the
/bin/sh
command. If any script exits with a non-zero value (which indicates the script did not execute correctly), the Gateway container startup terminates.Control the Order of Execution
If more than one script is present, they are executed in ascending alphabetical order. The easiest way to control the order is to add a prefix to the script names:
001_first_script.sh999_last_script.sh050_middle_script.sh