gpt4 book ai didi

docker-compose - CommandError :/code/manage. py 已经存在,将项目或应用程序覆盖到现有目录中不会替换冲突文件

转载 作者:行者123 更新时间:2023-12-04 17:34:40 26 4
gpt4 key购买 nike

我正在尝试在 Windows 上运行 linux docker 并收到此错误。

构建很好。

'''
$ docker-compose build
Building web
Step 1/11 : FROM python:3
---> 42d620af35be
Step 2/11 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> b43065732d6e
Step 3/11 : RUN apt-get update -y
---> Using cache
---> 6f65e0da9e14
Step 4/11 : RUN apt-get install -y unixodbc unixodbc-dev
---> Using cache
---> 2a9d7445a991
Step 5/11 : RUN easy_install pip
---> Using cache
---> 5994e6452e09
Step 6/11 : RUN mkdir /code
---> Using cache
---> d0eaa870fb98
Step 7/11 : WORKDIR /code
---> Using cache
---> af78d4b35f26
Step 8/11 : RUN pip uninstall django
---> Using cache
---> 92f983bfef88
Step 9/11 : COPY requirements.txt /code/
---> Using cache
---> 3c0031987286
Step 10/11 : RUN pip install -r requirements.txt
---> Using cache
---> 3915127d3d58
Step 11/11 : COPY . /code/
---> Using cache
---> de872685c733
Successfully built de872685c733
Successfully tagged djangoproject_web:latest
'''

但是当我运行 compose up.. 我看到以下错误。
'''
$ docker-compose up
Creating djangoproject_web_1 ... done
Attaching to djangoproject_web_1
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 |
web_1 | You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
web_1 | Run 'python manage.py migrate' to apply them.
web_1 | July 23, 2019 - 03:21:21
web_1 | Django version 2.2.3, using settings 'composeexample.settings'
web_1 | Starting development server at http://case.xxxxxx.com:8000/
web_1 | Quit the server with CONTROL-C.
web_1 | Error: [Errno -2] Name or service not known
djangoproject_web_1 exited with code 1
'''

如果我试试这个
'''
docker-compose run web django-admin startproject composeexample .
'''

它说
'''
CommandError: /code/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
'''

我的 Dockerfile 是
'''
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN apt-get update -y
RUN apt-get install -y unixodbc unixodbc-dev
RUN easy_install pip
RUN mkdir /code
WORKDIR /code
RUN pip uninstall django
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
'''

我的 docker-compose.yml 是
'''
版本:'3'
services:
web:
build: .
command: python manage.py runserver case.xxxxxx.com:8000
volumes:
- .:/code
ports:
- "8000:8000"

'''
我该如何解决 composeexample 的问题?它甚至没有被创建(因为我在文件夹中看不到它)。请你的建议。

最佳答案

您可能正在使用 Ubuntu Windows 子系统的 docker 客户端。这给 docker 的 Volume 特性带来了问题。
运行 docker run Windows powershell 上的命令,这个问题不会出现。

关于docker-compose - CommandError :/code/manage. py 已经存在,将项目或应用程序覆盖到现有目录中不会替换冲突文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57156398/

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