Unable to migrate Django db when using docker container
On my Windows 10 machine, I am developing a database manager. 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.
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.
I would like to play around with the
django-ldapdb package and for that I want to apply the migrations.
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. I suspect this is because the command does not use the remote Docker interpreter I set up with PyCharm.
The other thing I tried is using PyCharm’s dedicated
manage.py console. 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. I even tried running the app using PyCharm’s Django run config, which started a container, but still I get the same errors.
I googled a lot, but I couldn’t find more infos about remote interpreters nor something solving my issue.
One Solution collect form web for “Unable to migrate Django db when using docker container”
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
docker exec -ti contr /bin/bash