[英]Cannot mount local directory into container from docker-compose file
I want to mount the local directory of a project to docker container before I used COPY command but when I make changes I have to rebuild those parts which involve some installation from bash scripts.我想在使用 COPY 命令之前将项目的本地目录挂载到 docker 容器,但是当我进行更改时,我必须重建那些涉及从 bash 脚本进行某些安装的部分。
This is my docker-compose
file这是我的docker-compose
文件
version "3.7"
services
tesseract:
container_name: tesseract
build:
context: ./app/services/tesseract/
dockerfile: Dockerfile
volumes:
- ./app/services/tesseract:/tesseract/
I don't have any errors when building and my WORKDIR tesseract
is empty when i run container构建时我没有任何错误,运行容器时我的WORKDIR tesseract
为空
This is my Dockerfile这是我的 Dockerfile
FROM ubuntu:19.10
ENV DEBIAN_FRONTEND=noninteractive
ENV TESSERACT=/usr/share/tesseract
WORKDIR /tesseract
RUN apt-get update && apt-get install -y \
build-essential \
software-properties-common \
python3.7 \
python3-pip \
cmake \
autoconf \
automake \
libtool \
pkg-config \
libpng-dev \
tesseract-ocr \
libtesseract-dev \
libpango1.0-dev \
libicu-dev \
libcairo2-dev \
libjpeg8-dev \
zlib1g-dev \
libtiff5-dev \
wget \
git \
g++ \
vim
RUN git clone https://github.com/tesseract-ocr/tesseract $TESSERACT
COPY . /tesseract/
RUN chmod +x scripts/*
RUN scripts/compile_tesseract.sh
RUN scripts/langdata_lstm.sh scripts/start.sh
RUN pip3 install -r requirements.txt
ENV TESSDATA_PREFIX=/usr/share/tesseract/tessdata
Main objective of docker volume is docker volume 的主要目标是
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers.卷是持久化 Docker 容器生成和使用的数据的首选机制。
which means volumes are used to persist the data outside the lifecycle of a container.这意味着卷用于在容器的生命周期之外持久保存数据。 If you want to COPY
a file or a directory into a container, please use COPY
instruction.如果要将文件或目录COPY
到容器中,请使用COPY
指令。
If you're copying in local files to your Docker image, always use
COPY
because it's more explicit.如果您要将本地文件复制到 Docker 映像,请始终使用COPY
因为它更明确。
With Docker-compose, you can use a bind mount volume使用 Docker-compose,您可以使用绑定挂载卷
https://docs.docker.com/compose/gettingstarted/#step-5-edit-the-compose-file-to-add-a-bind-mount#step-5-edit-the-compose-file-to-add-a-bind-mount https://docs.docker.com/compose/gettingstarted/#step-5-edit-the-compose-file-to-add-a-bind-mount#step-5-edit-the-compose-file-to -add-a-bind-mount
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.