【问题标题】:How to mount the current working directory onto Docker container?如何将当前工作目录挂载到 Docker 容器中?
【发布时间】:2016-03-11 09:19:45
【问题描述】:

我正在尝试将当前工作目录挂载到 Docker 容器上,但无法正常工作。这是我的 Dockerfile

FROM ubuntu:14.04.3
MAINTAINER Upendra Devisetty

RUN apt-get update && apt-get install -y g++ \
                make \
                git \
                zlib1g-dev \
                python \
                wget \
                curl \
                python-matplotlib

ENV BINPATH /usr/bin
ENV HISAT2GIT https://upendra_35@bitbucket.org/upendra_35/evolinc.git

RUN git clone "$HISAT2GIT"
RUN chmod +x evolinc/evolinc-part-I.sh && cp evolinc/evolinc-part-I.sh $BINPATH
RUN wget -O- http://cole-trapnell-lab.github.io/cufflinks/assets/downloads/cufflinks-2.2.1.Linux_x86_64.tar.gz | tar xzvf -
RUN wget -O- https://github.com/TransDecoder/TransDecoder/archive/2.0.1.tar.gz | tar xzvf -
RUN wget -O- http://seq.cs.iastate.edu/CAP3/cap3.linux.x86_64.tar | tar vfx -
RUN curl ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.2.31+-x64-linux.tar.gz > ncbi-blast-2.2.31+-x64-linux.tar.gz
RUN tar xvf ncbi-blast-2.2.31+-x64-linux.tar.gz
RUN wget -O- http://ftp.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/q/qu/quast/quast-3.0.tar.gz | tar zxvf -
RUN curl -L http://cpanmin.us | perl - App::cpanminus
RUN cpanm URI/Escape.pm

ENV PATH /CAP3/:$PATH
ENV PATH /ncbi-blast-2.2.31+/bin/:$PATH
ENV PATH /quast-3.0/:$PATH
ENV PATH /cufflinks-2.2.1.Linux_x86_64/:$PATH
ENV PATH /TransDecoder-2.0.1/:$PATH
ENTRYPOINT ["/usr/bin/evolinc-part-I.sh"]
CMD ["-h"]

当我运行以下命令来挂载当前工作目录以确保一切正常时,我看到所有这些依赖项都安装在当前工作目录中。

docker run --rm -v $(pwd):/working-dir -w /working-dir ubuntu/evolinc:2.0 -c cuffcompare_out_annot_no_annot.combined.gtf -g Brassica_rapa_v1.2_genome.fa -r Brassica_rapa_v1.2_cds.fa -b TE_RNA_transcripts.fa

我认为,它们应该只安装在容器上,并且只会在当前工作目录中生成输出。抱歉,我对 Docker 很陌生,我需要一些帮助......

【问题讨论】:

  • 我对您的期望感到困惑。你期待发生什么?这听起来更依赖于应用程序如何使用当前工作目录。
  • 通过将目录绑定挂载到容器中,您明确地授予容器中的进程访问主机上该目录的权限。因此宿主机上的目录和容器内的目录是同一个目录;容器内写入该目录的任何内容,因此将有效地写入主机上的目录。
  • 如果您想“调试”进程以查看它是否有效,您可以考虑使用docker exec -it <container-name> bash 在容器内打开交互式shell 作为辅助进程

标签: docker


【解决方案1】:

在 docker (-v) 中安装卷允许容器与主机共享目录/卷。因此,在更改卷时,您实际上是在更改挂载目录。如果您想复制一些文件,而不是指向它们,您可能需要构建自己的容器并使用COPYADD 指令。 p>

What is the difference between the `COPY` and `ADD` commands in a Dockerfile?

【讨论】:

  • 使用-v 的示例将完成答案。
猜你喜欢
  • 2016-06-10
  • 1970-01-01
  • 1970-01-01
  • 2019-07-08
  • 1970-01-01
  • 2023-03-03
  • 1970-01-01
  • 1970-01-01
  • 2020-03-08
相关资源
最近更新 更多