遵循 docker-compose 教程时未创建 django 应用程序 [英] no django app created when following the docker-compose tutorial

查看:27
本文介绍了遵循 docker-compose 教程时未创建 django 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 docker-compose 教程,试图找出如何部署 django 应用程序:http://docs.docker.com/compose/django/

I'm following the docker-compose tutorial, to try and figure out how to get a django app to deploy: http://docs.docker.com/compose/django/

一切都很顺利(应用程序甚至可以运行!)但是 django 项目文件夹 composeexample 没有在我的本地项目目录中创建.

And everything's going smoothly (the app even works!) but the django project folder composeexample isn't created in my local project directory.

我留下了一个有效的It Works!"运行后的页面:

I'm left with a working "It Works!" page after running:

$ docker-compose run web django-admin.py startproject composeexample .

但我无法继续编辑 composeexample/settings.py,正如教程所建议的:该文件夹在我的机器上不存在(它确实存在于容器中,但不是在那里对我很好!)

But I can't continue to edit the composeexample/settings.py, as the tutorial suggests: The folder doesn't exist on my machine (it does exist in the container, but it's no good to me there!)

教程错了吗?我是不是没跟上?

谢谢!

更新:

问题来了,我使用 docker-machine 通过远程 docker 实例运行整个过程.使用远程 docker 机器时,本地文件夹共享的规则是否不同?

Here's the problem, I'm using docker-machine to run this whole process through a remote docker instance. Are the rules about local folder sharing different when using a remote docker machine?

推荐答案

您需要设置一个 dockerfile,以便在您进行 docker build 时,它会将您的本地代码复制到容器中.首先,您需要将文件从容器复制到本地.看这里.或者只是用你自己的 django 应用程序覆盖目录

You need to set up a dockerfile so that when you do a docker build, it copies your local code onto the container. To get started, you will need to copy the files from container to local. Look here for that. Or just overwrite the directory with your own django app

将文件从主机复制到 Docker 容器

示例:

FROM python:2.7
RUN mkdir /code
WORKDIR /code
ADD . /code/

这篇关于遵循 docker-compose 教程时未创建 django 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆