Best practices for running API management in Docker containers
2 minute read
Reduce Docker image size
The API Gateway Docker image created with the standard Docker sample scripts has a considerable size. Follow these steps to reduce the size of the image by around 200 MB.
The scripts are provided as an example and you can adjust them as needed for your requirements.
Reduce the size of base images
To remove files and folders which are not required in the base images:
-
Download the Docker samples (
APIGateway_7.7.YYYYMMDD-<bn>_DockerScripts.tar.gz
) and extract the package. -
In the extracted package open the file
Dockerfiles/gateway-base/scripts/runInstall.sh
. -
Add a line starting with
rm -rf
to remove any files you do not require from the image. For example:# removes some sample McAfee DAT files /opt/Axway/apigateway/conf/plugin # removes the IBM-MQ driver, which might not be required in your environment /opt/Axway/apigateway/system/lib/ibmmq # Database setup scripts not required as part of the Docker container /opt/Axway/apigateway/system/conf/sql # Not required MIB description /opt/Axway/apigateway/system/conf/snmp # Policy configuration templates not required as part of the Docker container /opt/Axway/apigateway/system/conf/templates/* # Sample SpiderLabs Mod-Security pattern /opt/Axway/apigateway/system/conf/threat-protection/SpiderLabs-owasp-modsecurity-crs-2.2.9-7-g3e6782b.zip # Gateway Metrics plugin for Oracle Enterprise Manager also not required /opt/Axway/apigateway/system/conf/oracle-em # Configuration migration artifacts /opt/Axway/apigateway/system/conf/migrate # Provided samples not required as part of the Docker container /opt/Axway/apigateway/samples # If you don't need the SDK-Generator you can remove it as well /opt/Axway/apigateway/tools/sdk-generator
Download
runInstall.sh
for a complete example.It is best to version control any changes you make in the file.
After these changes, the size of the generated Docker base images is reduced from 947MB to 747MB.
Optimize images for Node Manager and API Gateways
In addition, you can create a layered multi-stage image for Admin Node Manager and the API Gateways and in these images you can remove additional folders that are not required.
-
Open the file
Dockerfiles/emt-nodemanager/Dockerfile
. -
Change the line
FROM $PARENT_IMAGE
toFROM $PARENT_IMAGE as base
. -
Add the following line at the end before the
CMD
instruction:FROM centos:7 COPY --from=base /opt/Axway/apigateway /opt/Axway/apigateway
-
Remove the folders that you do not require. Download the following complete example files to learn which folders you can remove in each image:
This reduces the size of the API Gateway image to 715 MB and the Admin Node Manager image to 708 MB.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.