简体   繁体   English

docker-compose和django错误

[英]error with docker-compose and django

I am trying to get started with docker and django. 我正在尝试使用docker和django。 I followed the directions of docker-compose and created an image with a simple requirements.txt. 我按照docker-compose的指示进行操作,并使用简单的requirements.txt创建了一个映像。

I now want to actually build out my app more and add templates and actual code. 现在,我实际上想进一步构建我的应用程序,并添加模板和实际代码。

1) i installed some modules on the host machine and added them to the requirements.txt file 1)我在主机上安装了一些模块,并将它们添加到requirements.txt文件中

2) i run (again) docker-compose run web django-admin.py startproject exampleproject. 2)我再次运行docker-compose运行web django-admin.py startproject exampleproject。 All my new requirements get downloaded but then i get this error: 我所有的新要求都已下载,但随后出现此错误:

/code/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files /code/manage.py已存在,将项目或应用程序覆盖到现有目录中不会替换冲突的文件

I am using the exact Dockerfile and docker-compose.yml as here: http://docs.docker.com/compose/django/ 我在这里使用的是确切的Dockerfile和docker-compose.yml: http ://docs.docker.com/compose/django/

how am i supposed to update the container/image with new templates/views &c and new modules as i am developing my app? 我在开发应用程序时应如何使用新模板/视图&c和新模块更新容器/图像?

am i using docker wrong? 我使用docker错误吗?

thanks. 谢谢。

I needed to remove the manage.py from the directory where i had my project (the directory where the docker-compose.yml is in). 我需要从我拥有项目的目录(docker-compose.yml所在的目录)中删除manage.py。

I guess once you start a project, you install new requirements on the container itself and add them to requirements.txt for the next time you build your project from scratch. 我想一旦开始一个项目,便会在容器本身上安装新的需求,并将其添加到Requirements.txt中,以供下一次从头开始构建项目时使用。

Sorry for the late addition but I thought it might help someone. 对不起,我很晚才加入,但我认为这可能会对某人有所帮助。 I had also encountered this same problem and inspite of removing manage.py from the folder where my .yml and Dockerfile existed, it gave me same error. 我也遇到了同样的问题,尽管从我的.yml和Dockerfile所在的文件夹中删除了manage.py,但它给了我同样的错误。

I have no idea where it made the code directory which had the manage.py file. 我不知道它在哪里创建了具有manage.py文件的代码目录。 But I worked around it presently by changing the service name in the yml file and restarting the project with the new service name. 但是我现在通过更改yml文件中的服务名称并使用新的服务名称重新启动项目来解决此问题。

docker-compose run newservicenm django-admin.py startproject projectname directoryname

This worked as a new container! 这作为一个新的容器!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM