Build Docker Image
Dockerfile
There is a Dockerfile file in the root directory of the project from which you can build the docker image. There are two build methods in Dockerfile to choose from.
When executing the build command, use the --build-arg parameter to control the image version. The --build-arg parameter defaults to yes, which builds the stable version of the qlib image.
1.For the stable version, use pip install pyqlib to build the qlib image.
docker build --build-arg IS_STABLE=yes -t <image name> -f ./Dockerfile .
docker build -t <image name> -f ./Dockerfile .
For the
nightlyversion, use current source code to build the qlib image.
docker build --build-arg IS_STABLE=no -t <image name> -f ./Dockerfile .
Auto build of qlib images
There is a build_docker_image.sh file in the root directory of your project, which can be used to automatically build docker images and upload them to your docker hub repository(Optional, configuration required).
sh build_docker_image.sh
>>> Do you want to build the nightly version of the qlib image? (default is stable) (yes/no):
>>> Is it uploaded to docker hub? (default is no) (yes/no):
If you want to upload the built image to your docker hub repository, you need to edit your build_docker_image.sh file first, fill in
docker_userin the file, and then execute this file.
How to use qlib images
Start a new Docker container
docker run -it --name <container name> -v <Mounted local directory>:/app <image name>
At this point you are in the docker environment and can run the qlib scripts. An example:
>>> python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
>>> python qlib/cli/run.py examples/benchmarks/LightGBM/workflow_config_lightgbm_Alpha158.yaml
Exit the container
>>> exit
Restart the container
docker start -i -a <container name>
Stop the container
docker stop -i -a <container name>
Delete the container
docker rm <container name>
For more information on using docker see the docker documentation.