【发布时间】:2022-10-13 08:01:22
【问题描述】:
我制作了 Dockerfile,用于制作可从 AWS Batch 运行的 Docker 映像,包含多个层,将文件复制到“/opt”,我将其设置为WORKDIR。
我必须运行一个名为“BLAST”的程序,它是一个单独的 .exe 程序,需要几个参数,包括 DB 的位置。
当我运行映像时,出现错误,找不到安装的数据库位置。完整的错误消息是 b'BLAST Database error: No alias or index file found for nucleotide database [/mnt/fsx/ntdb/nt] in search path [/opt:/fsx/ntdb:]\n'],其中/mnt/fsx/ntdb/nt 是数据库路径。
唯一的假设是因为我在 Dockerfile 中提供了 WORKDIR,所以默认工作区设置为“/opt:”。
我想知道我应该如何解决这个问题。通过删除 WORKDIR ?或者是其他东西?
我的 Dockerfile 如下所示
# Set Work dir
ARG FUNCTION_DIR="/opt"
# Get layers
FROM (aws-account).dkr.ecr.(aws-region).amazonaws.com/uclust AS layer_1
FROM (aws-account).dkr.ecr.(aws-region).amazonaws.com/blast AS layer_2
FROM public.ecr.aws/lambda/python:3.9
# Copy arg and set work dir
ARG FUNCTION_DIR
COPY . ${FUNCTION_DIR}
WORKDIR ${FUNCTION_DIR}
# Copy from layers
COPY --from=layer_1 /opt/ .
RUN true
COPY --from=layer_2 /opt/ .
RUN true
COPY . ${FUNCTION_DIR}/
RUN true
# Copy and Install required libraries
COPY requirements.txt .
RUN true
RUN pip3 install -r requirements.txt
# To run lambda handler
RUN pip install \
--target "${FUNCTION_DIR}" \
awslambdaric
# To run blast
RUN yum -y install libgomp
# See files inside image
RUN dir -s
# Get permissions for files
RUN chmod +x /opt/main.py
RUN chmod +x /opt/mode/submit/main.py
# Set Entrypoint and CMD
ENTRYPOINT [ "python3" ]
CMD [ "-m", "awslambdaric", "main.lambda_handler" ]
编辑:我发现的更多信息,当查看错误时,BLAST 程序试图在路径/opt:/fsx/ntdb: 处搜索 db,这是 Dockerfile 中设置为WORKDIR 的路径和os.environ.['BLASTDB'] 设置的 BLASTDB 路径的组合(@ 987654321@.)。
【问题讨论】:
-
该错误消息似乎表明与 Docker 或 Python 无关的问题。数据库来自哪里,它的索引是如何创建的?
-
WORKDIR完全按照它所说的去做;或许也可以看看 What exactly is current working directory? 你可以在运行时使用docker run -w轻松覆盖它 -
@tripleee 该数据库位于 AWS 的文件系统 (luster) 中,它安装在 AWS Batch 的作业定义上。因此,每当创建作业时,都会创建安装了数据库的 EC2 实例。我不确定数据库的索引,因为它不是由我创建的。我只从提供的 NCBI 下载并推送到文件系统。
-
@tripleee 我没有考虑过覆盖工作目录。我不需要发送和
docker run命令,因为提交 AWS Batch 作业为我完成。但我可以看看任何方法来覆盖它。谢谢 -
挂载是只读的吗?我猜您正在使用的工具会在运行时创建一个索引,但这显然是推测性的,无论如何都不是真正的编程问题。
标签: python linux docker aws-batch blast