I'm trying to run a project that uses Django and uWSGI in a Docker container. But I'm new to Docker and uWSGI so I'm not quite sure how I'm supposed to do it.
At first I build the project with the below command:

docker build -t saleor .

Then I run it:

docker run --env SECRET_KEY="<the key>" -p 4000:80 saleor

And this is what I get:

[uWSGI] getting INI configuration from /app/saleor/wsgi/uwsgi.ini
[uwsgi-static] added mapping for /static => /app/static
*** Starting uWSGI 2.0.15 (64bit) on [Tue Dec 19 14:02:19 2017] ***
compiled with version: 4.9.2 on 19 December 2017 09:11:22
os: Linux-4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017
nodename: 88adfd3f2e93
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /app
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
building mime-types dictionary from file /etc/mime.types...547 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8000 fd 3
Python version: 3.5.4 (default, Dec 12 2017, 16:43:39)  [GCC 4.9.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x12277b0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x12277b0 pid: 1 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 10, cores: 1)

Then I don't know what I'm supposed to do. Usually with Django applications, I just would check "localhost:4000" in my browser. But it doesn't work in this case and I get nothing. So...what am I supposed to do?
thanks

I set the PORT environmental variable to 80 for the docker and now I'm getting something. But that something is an error!

could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

I just understood something. "docker run" only starts a single container. But some projects use multiple containers for different services(like this one) and for them, docker-compose should be used. The problem was that the database was just in another container. So using "docker-compose up" solved the issue.

Although I now have another issue, which seems to need a peek inside the database. Does anyone know how I can log in to a database inside a container?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.