Docker deployment and django

I have a feeling some of you may have experience with Docker, me however - I am just beginning to learn. I have had huge trouble trying to make a docker-compose build on windows. I don’t want to get into the detail of my configuration, I just want to say that even after setting up WSL 2 (installing a linux app on windows), I had the same issues - the requirements.txt file never working with uWSGI. It has gotten to the point where I feel the docker technology isn’t mature enough for windows, and I’m reverting to using Linux.
I simply want to ask - which Linux distribution would you recommend for creating a docker deployment? does it matter as long as it’s a stable recent build? I’m not sure if using linux on a VM with vmware or something would be sufficient as it might limit the dependencies I can install - do you have any thoughts on that? Right now I’m thinking I should install a full linux distro through a USB.

You can probably use anything as long as it provides a container daemon and supports the docker commands.

I regularly do docker-based development using virtual machines in either VirtualBox or VMWare. There are no limits regarding what you can install in either of them. They really are complete virtualized environments. In practice, you can’t tell the difference between them and a native installation unless you go looking for those differences.

We also use uWSGI - we have created a base docker package where the instance of uWSGI was built for the base container. All our application containers are built from that as the base.

That’s interesting, I might try VirtualBox.

I’m experimenting with this again on windows, just to try and understand why this could be happening:
When I run docker-compose up, and it gets to the point in the Dockerfile where it’s installing the dependencies from the requirements.txt file, it is fine installing everything aside from psycopg2, it always stops at psycopg2 and gives me this error which I don’t understand:

What do you not understand about it?

It seems pretty clear to me what’s happening and what you need to do to resolve it.

You can also read the description at psycopg2 · PyPI

I tried installing psycopg2-binary with pip and updated the requirements file, but I’m still getting a “metadata” error on psycopg2 during the build, I also have no “pg_config” path and I’m confused about this

Did you also remove psycopg2 from your requirements file?

If so, please copy/paste the output from your docker command generating this new error. (No screen images please.)

From the error message you quoted above:

pg_config is required to build psycopg2 from source.

If you’re not building psycopg2 from source, then you don’t need to worry about it.

I had previously tried removing psycopg2 from the requirements file, but Dockerfile still loads it somehow, and I don’t know why. I’m not even using a postgres database right now in the settings file.
I have just seen online a lot of people have problems with this, could it be that I need an architecture-specific version of psycopg2 to satisfy docker? I’m feeling that windows is the issue but I don’t know.

Someone wrote:

pg_config is in postgresql-devel (libpq-dev in Debian/Ubuntu, libpq-devel on Centos/Fedora/Cygwin/Babun.)

but I don’t think this can be installed on windows

the following is the error from my terminal:

#10 17.79 Collecting psycopg2==2.8.6
#10 17.83 Downloading psycopg2-2.8.6.tar.gz (383 kB)
#10 17.93 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 383.8/383.8 kB 4.3 MB/s eta 0:00:00
#10 18.21 Preparing metadata (setup.py): started
#10 19.59 Preparing metadata (setup.py): finished with status ‘error’
#10 19.62 error: subprocess-exited-with-error
#10 19.62
#10 19.62 × python setup.py egg_info did not run successfully.
#10 19.62 │ exit code: 1
#10 19.62 ╰─> [23 lines of output]
#10 19.62 running egg_info
#10 19.62 creating /tmp/pip-pip-egg-info-2ef_vtvt/psycopg2.egg-info
#10 19.62 writing /tmp/pip-pip-egg-info-2ef_vtvt/psycopg2.egg-info/PKG-INFO
#10 19.62 writing dependency_links to /tmp/pip-pip-egg-info-2ef_vtvt/psycopg2.egg-info/dependency_links.txt
#10 19.62 writing top-level names to /tmp/pip-pip-egg-info-2ef_vtvt/psycopg2.egg-info/top_level.txt
#10 19.62 writing manifest file ‘/tmp/pip-pip-egg-info-2ef_vtvt/psycopg2.egg-info/SOURCES.txt’
#10 19.62
#10 19.62 Error: pg_config executable not found.
#10 19.62
#10 19.62 pg_config is required to build psycopg2 from source. Please add the directory
#10 19.62 containing pg_config to the $PATH or specify the full executable path with the
#10 19.62 option:
#10 19.62
#10 19.62 python setup.py build_ext --pg-config /path/to/pg_config build …
#10 19.62 or with the pg_config option in ‘setup.cfg’.
#10 19.62
#10 19.62 For further information please check the ‘doc/src/install.rst’ file (also at
#10 19.62 https://www.psycopg.org/docs/install.html).
#10 19.62 [end of output]
#10 19.62
#10 19.63 error: metadata-generation-failed
#10 19.63
#10 19.63 × Encountered error while generating package metadata.
#10 19.63 ╰─> See above for output.
#10 19.63
#10 19.63 note: This is an issue with the package mentioned above, not pip.
#10 19.63 hint: See above for details.

It would likely be a different library that identifies it as a prerequisite. Re-examine your requirements.txt file to ensure you don’t have anything in it that you don’t need.

You can also use something like pipdeptree to identify what is looking for a specific project - psycopg2 in this case.

thanks, that seems like a good tool, I’ll try that

Did you get any results? this is now my question too -_-

I got it deployed and working, where are you stuck?

BTW I got it working on Windows too using a Kali Linux app. But you mightn’t need to use WSL2