# Docker 环境使用说明 ## 快速开始 ### 1. 环境变量配置 ```bash # 复制环境变量模板 cp docker/docker.env.example docker/.env # 编辑环境变量 vim docker/.env ``` ### 2. 构建镜像 ```bash # 使用默认配置构建 docker-compose -f docker/docker-compose.yml build # 使用环境变量构建 docker-compose -f docker/docker-compose.yml --env-file docker/.env build # 或者直接使用 docker build docker build -f docker/Dockerfile -t vinatools:latest . ``` ### 3. 环境变量说明 | 变量名 | 默认值 | 说明 | |--------|--------|------| | `VINA_VERSION` | `1.2.7` | AutoDock Vina 版本 | | `TARGETPLATFORM` | `linux/amd64` | 目标平台架构 | **支持的平台:** - `linux/amd64` - Linux x86_64 - `linux/arm64` - Linux aarch64 ### 4. 从源码编译 Dockerfile 现在支持从源码编译 AutoDock Vina: - **Python 环境**: Python 3.12 - **依赖包**: numpy (最新版本)、boost-cpp 1.82.0、swig 4.0.2 - **编译方式**: 使用 pixi 管理环境,从源码编译 - **版本控制**: 通过 VINA_VERSION 参数控制,默认 1.2.7 ### 4. 运行容器 ```bash # 启动主服务 docker-compose -f docker/docker-compose.yml up -d vinatools # 进入容器 docker-compose -f docker/docker-compose.yml exec vinatools bash # 或者直接运行 docker run -it --rm -v $(pwd):/app vinatools:latest bash ``` ## 使用示例 ### 不同平台构建 ```bash # Linux x86_64 平台 TARGETPLATFORM=linux/amd64 docker-compose -f docker/docker-compose.yml build # Linux ARM64 平台 TARGETPLATFORM=linux/arm64 docker-compose -f docker/docker-compose.yml build # 使用不同版本 VINA_VERSION=1.2.6 TARGETPLATFORM=linux/amd64 docker-compose -f docker/docker-compose.yml build ``` ### 使用环境文件 ```bash # 创建自定义环境文件 cat > docker/my.env << EOF VINA_VERSION=1.2.6 TARGETPLATFORM=linux/amd64 EOF # 使用自定义环境文件构建 docker-compose -f docker/docker-compose.yml --env-file docker/my.env build ``` ### 3. 使用 Jupyter Notebook ```bash # 启动 Jupyter 服务 docker-compose -f docker/docker-compose.yml up -d jupyter # 访问 http://localhost:8888 ``` ## 环境说明 ### 镜像源配置 为了加速构建过程,Dockerfile 中配置了以下镜像源: - **APT 源**: 阿里云镜像 (mirrors.aliyun.com) - **pip 源**: 清华大学镜像 (pypi.tuna.tsinghua.edu.cn) - **conda 源**: 清华大学镜像 (mirrors.tuna.tsinghua.edu.cn) ### 包含的包 - **rdkit**: 化学信息学工具包 - **openbabel**: 分子格式转换工具 - **meeko**: 分子准备工具 - **AutoDock Vina**: 分子对接工具 ### 目录结构 ``` /app/ ├── bin/ # AutoDock Vina 二进制文件 ├── scripts/ # Python 脚本 ├── data/ # 输入数据(挂载) └── results/ # 输出结果(挂载) ``` ## 常用命令 ### 运行脚本 ```bash # 在容器中运行 Python 脚本 pixi run python scripts/calculate_qed_values.py # 运行批处理脚本 pixi run bash scripts/batch_docking.sh ``` ### 数据管理 ```bash # 挂载数据目录 docker run -it --rm \ -v $(pwd)/data:/app/data \ -v $(pwd)/results:/app/results \ vinatools:latest bash ``` ### 清理 ```bash # 停止所有服务 docker-compose -f docker/docker-compose.yml down # 删除镜像 docker rmi vinatools:latest # 清理未使用的资源 docker system prune -a ``` ## 故障排除 ### 网络连接问题 如果遇到网络连接问题,可以尝试以下解决方案: ```bash # 1. 使用代理构建 docker build --build-arg HTTP_PROXY=http://proxy:port \ --build-arg HTTPS_PROXY=http://proxy:port \ -f docker/Dockerfile -t vinatools:latest . # 2. 使用不同的镜像源 # 编辑 Dockerfile,替换镜像源: # - APT: mirrors.ustc.edu.cn (中科大) # - pip: pypi.douban.com (豆瓣) # - conda: mirrors.ustc.edu.cn/anaconda/cloud/ # 3. 离线构建(如果网络完全不可用) # 预先下载所有依赖包,然后使用本地构建 ``` ### 权限问题 ```bash # 修复文件权限 sudo chown -R $USER:$USER data/ results/ ``` ### 内存不足 ```bash # 增加 Docker 内存限制 docker run -it --rm --memory=8g vinatools:latest bash ``` ### 网络问题 ```bash # 使用主机网络 docker run -it --rm --network=host vinatools:latest bash ``` ### 镜像源切换 如果需要使用其他镜像源,可以修改 Dockerfile 中的配置: ```dockerfile # APT 源切换 RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list # pip 源切换 RUN echo "index-url = https://pypi.douban.com/simple" > /root/.pip/pip.conf # conda 源切换 RUN /root/.pixi/bin/pixi config set channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ ```