构建 Docker 镜像

时间:2021-03-24 04:10:43

标签: docker nextflow

我正在尝试使用 Dockerfile 构建我自己的 docker 镜像。但是,Docker 映像存在问题。这是我的 dockerfile。第一次,它说成功构建镜像;但是,有些包不起作用(诸如权限被拒绝和命令未找到等错误),因此我决定删除所有映像和容器以重建此映像。它一直说使用缓存而不是重新安装所有软件包。当我使用这个docker时,它一开始就失败了。

FROM ubuntu:18.04
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
RUN apt-get update

RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/*

RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && mkdir /root/.conda \
    && bash Miniconda3-latest-Linux-x86_64.sh -b \
    && rm -f Miniconda3-latest-Linux-x86_64.sh 
RUN conda --version

RUN conda config --add channels defaults

RUN conda config --add channels bioconda

RUN conda config --add channels conda-forge

RUN conda install -c bioconda bowtie2 fastqc samtools ucsc-bedsort ucsc-bedgraphtobigwig bedtools deeptools homer seacr

1 个答案:

答案 0 :(得分:1)

就像评论中的其他人所说的那样,您的 Dockerfile 构建正确,并且应该使用 docker run 按预期工作。我有一些使用 Nextflow 构建和运行 Docker 容器的经验,所以我想分享一下我构建包含运行工作流所需的所有包的容器的经验。

首先,考虑将所需的包移动到 environment.yml 文件中。这将有助于将您项目的所有依赖项保存在一个地方:

name: my-awesome-project
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - bowtie2
  - fastqc
  - samtools
  - ucsc-bedsort
  - ucsc-bedgraphtobigwig
  - bedtools
  - deeptools
  - homer
  - seacr

其次,考虑从 continuumio/miniconda3 构建您的 Dockerfile:

FROM continuumio/miniconda3:4.9.2

RUN apt-get update \
    && apt-get install -y procps \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*

COPY environment.yml /

RUN conda env create -f /environment.yml \
    && conda clean -a

ENV PATH /opt/conda/envs/my-awesome-project/bin:$PATH

COPY install_packages.R /
COPY bed_convert.R /
COPY cut_tag_fingerprint_cmd.R /

RUN Rscript install_packages.R
CMD ["Rscript", "bed_convert.R"]
CMD ["Rscript", "cut_tag_fingerprint_cmd.R"]

最后,将 Conda 和 Docker 的配置文件添加到您的 nextflow.config 文件中。也许类似以下内容就足够了:

process.container = 'my-awesome-project:v1.0'

profiles {
  conda { process.conda = "${baseDir}/environment.yml" }
  docker { docker.enabled = true }
  singularity { singularity.enabled = true }
}