This Docker image code sample demonstrates how to install the STK Engine for Linux Python API in a containerized environment.
- Docker must be running on your system.
- Access to an Ansys Licensing Server with a valid STK license. Edit the
licensing.envfile to ensure theANSYSLMD_LICENSE_FILEenvironment variable has your Ansys License Server information. - You have already built the
stk-engine-baselineimage.
This image is built using the yum and pip tools to install package dependencies. Please see the
custom-environment Docker image code sample project and build the
ansys/stk/stk-engine-custom-baseline:{version}-centos7 image, if needed, before proceeding with this image.
If you did not build the custom-environment image described above, run
docker build -t ansys/stk/stk-engine-python:{version}-centos7 . on the command line in this directory after replacing {version} with the version number. i.e 12.6.0
If you did build the custom-environment image described above, run
docker build -t ansys/stk/stk-engine-python:{version}-centos7 --build-arg baseImage=ansys/stk/stk-engine-custom-baseline:{version}-centos7 .
on the command line in this directory after replacing {version} with the version number. i.e 12.6.0
This image starts the python3 interpreter when starting the container. You can verify that
STK Engine is working inside the stk-engine-python container with the following steps:
- Run the following command from this directory after replacing
{version}with the version number. i.e12.6.0:docker run -it --env-file ../configuration/licensing.env --name stk-python --rm ansys/stk/stk-engine-python:{version}-centos7 - Execute the following Python commands and verify it returns a valid response:
from agi.stk12.stkengine import STKEngine stk = STKEngine.StartApplication(noGraphics=True) print(stk.Version)
- Quit the Python interpreter and the container by executing the command
quit()
- If you built the
custom-environmentimages described in the Special Configuration section, edit thedocker-compose.ymlfile to set the value of thebaseImagebuild argument toansys/stk/stk-engine-custom-baseline:{version}-centos7after replacing{version}with the version number. i.e12.6.0 - Run
docker compose buildon the command line in this directory.
This image starts the python3 interpreter when starting the container. You can verify that
STK Engine is working inside the stk-engine-python container with the following steps:
- On the command line, run
docker compose run --rm stk-engine-python. - Execute the following Python commands and verify it returns a valid response:
from agi.stk12.stkengine import STKEngine stk = STKEngine.StartApplication(noGraphics=True) print(stk.Version)
- Quit the Python interpreter and the container by executing the command
quit()