构建Docker映像 [英] Building Docker images

查看:60
本文介绍了构建Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to build my own docker image using Dockerfile. However, there is something wrong with the Docker image. Here is my dockerfile. At first time, it said successfully built the image; however, some of the package is not working(errors like permission denied and command not found), so I decided to remove all the image and container to rebuild this image. It kept saying using cache instead of reinstall all the packages. When I use this docker, it fails at the very beginning.

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

推荐答案

与评论中的其他内容一样,您的Dockerfile可以正确构建,并且可以使用 docker run 正常工作.我有一些使用 Nextflow 来构建和运行Docker容器的经验,所以我想与我分享构建一个Docker容器的经验.容器,其中包含运行您的工作流程所需的所有软件包.

Like others in the comments have stated, your Dockerfile builds correctly and should work as expected using docker run. I have some experience building and running Docker containers using Nextflow, so I thought I'd share my experience building a container that contains all the packages required to run your workflow.

首先,考虑将所需的软件包移至

Firstly, consider moving your required packages into an environment.yml file. This will help keep all your project's dependencies in one place:

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

第二,请考虑改为从 continuumio/miniconda3 构建您的Dockerfile:

Secondly, consider instead building your Dockerfile from continuumio/miniconda3:

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中文件.也许可以满足以下要求:

Finally, add profiles for Conda and Docker to your nextflow.config file. Perhaps something like the following will suffice:

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

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

这篇关于构建Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆