简体   繁体   English

使用Docker容器时无法迁移Django db

[英]Unable to migrate Django db when using docker container

On my Windows 10 machine, I am developing a database manager. 在Windows 10计算机上,我正在开发数据库管理器。 Because the backend uses LDAP and the required development libraries are only available for Linux, I want to use Docker to set up an environment with the appropriate libs. 因为后端使用LDAP并且所需的开发库仅适用于Linux,所以我想使用Docker来设置具有适当库的环境。

I managed to write a Dockerfile and compose file, that launch the (currently very basic) Django app in a Docker container with all the libs necessary. 我设法编写了一个Dockerfile和撰写文件,该文件在Docker容器中启动了(目前非常基本的)Django应用程序,并带有所有必需的库。
I would like to play around with the django-ldapdb package and for that I want to apply the migrations. 我想玩django-ldapdb软件包,为此,我想应用迁移。

When I open PyCharm's terminal and try to execute python manage.py migrate , I get an error telling me that the module ldapdb is not found. 当我打开PyCharm的终端并尝试执行python manage.py migrate ldapdb ,我收到一条错误消息,告诉我找不到模块ldapdb I suspect this is because the command does not use the remote Docker interpreter I set up with PyCharm. 我怀疑这是因为该命令未使用我通过PyCharm设置的远程Docker解释器。
The other thing I tried is using PyCharm's dedicated manage.py console. 我尝试过的另一件事是使用PyCharm专用的manage.py控制台。 This does not initialize properly. 这无法正确初始化。 It says the working directory is invalid and needs to be an absolute path, although the path it shows it the absolute path to the project. 它说工作目录无效,并且必须是绝对路径,尽管该路径显示它是项目的绝对路径。

I have to admit that I have no idea how this remote interpreter works and I don't see any Docker container running, so I might have not understood something properly here. 我不得不承认我不知道这个远程解释器是如何工作的,而且我看不到任何Docker容器正在运行,因此我可能在这里不太了解某些内容。 I even tried running the app using PyCharm's Django run config, which started a container, but still I get the same errors. 我什至尝试使用PyCharm的Django run config运行该应用程序,该配置启动了一个容器,但仍然出现相同的错误。

I googled a lot, but I couldn't find more infos about remote interpreters nor something solving my issue. 我在Google上搜索了很多,但找不到更多有关远程解释器的信息,也找不到解决我问题的方法。

The only way I managed to do this, is by executing the command inside the container. 我设法做到这一点的唯一方法是通过在容器内执行命令。

To get inside a container named contr , use the docker command 要进入名为contr的容器,请使用docker命令

docker exec -ti contr /bin/bash

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

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