gpt4 book ai didi

docker - 在 Windows 中使用 docker-compose 创建挂载源路径时出错

转载 作者:行者123 更新时间:2023-12-02 18:00:26 24 4
gpt4 key购买 nike

我正在尝试通过对每个应用进行泊坞化并使用 docker-compose 来泊坞化我的 React-Flask 应用程序把它们放在一起。

这里Dockerfile每个应用程序的 s 看起来像:

React - 前端

FROM node:latest

WORKDIR /frontend/

ENV PATH /frontend/node_modules/.bin:$PATH

COPY package.json /frontend/package.json
COPY . /frontend/
RUN npm install --silent
RUN npm install react-scripts@3.0.1 -g --silent

CMD ["npm", "run", "start"]

Flask - 后端
#Using ubuntu as our base
FROM ubuntu:latest

#Install commands in ubuntu, including pymongo for DB handling
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
RUN python -m pip install pymongo[srv]

#Unsure of COPY command's purpose, but WORKDIR points to /backend
COPY . /backend
WORKDIR /backend/

RUN pip install -r requirements.txt

#Run order for starting up the backend
ENTRYPOINT ["python"]
CMD ["app.py"]

当我只使用 docker build 时,它们中的每一个都可以正常工作和 docker up .我已经检查过它们在构建和独立运行时工作正常。然而,当我 docker-compose up docker-compose.yml看起来像
# Docker Compose
version: '3.7'

services:
frontend:
container_name: frontend
build:
context: frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- '.:/frontend'
- '/frontend/node_modules'
backend:
build: ./backend
ports:
- "5000:5000"
volumes:
- .:/code

给我下面的错误
Starting frontend                ... error
Starting dashboard_backend_1 ...

ERROR: for frontend Cannot start service sit-frontend: error while creating mount source path '/host_mnt/c/Users/myid/DeskStarting dashboard_backend_1 ... error

ERROR: for dashboard_backend_1 Cannot start service backend: error while creating mount source path '/host_mnt/c/Users/myid/Desktop/dashboard': mkdir /host_mnt/c: file exists

ERROR: for frontend Cannot start service frontend: error while creating mount source path '/host_mnt/c/Users/myid/Desktop/dashboard': mkdir /host_mnt/c: file exists

ERROR: for backend Cannot start service backend: error while creating mount source path '/host_mnt/c/Users/myid/Desktop/dashboard': mkdir /host_mnt/c: file exists
ERROR: Encountered errors while bringing up the project.

这是因为我使用的是 Windows 吗?可能是什么问题?提前致谢。

最佳答案

对我来说,唯一有效的方法是重新启动 Docker 守护进程

关于docker - 在 Windows 中使用 docker-compose 创建挂载源路径时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58194772/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com