I'am 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.
First I built the project with this command:
docker build -t saleor .
Then I ran 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)
Now I don't know what I am supposed to do. Usually with Django applications, I would just 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?
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?
I'm not used to docker. Do you know where do you pull the source from ?
https://github.com/mirumee/saleor-demo
For example here, I can see in the Dockerfile
And in Django the server points to 8000 too (see docker-compose.yml)
I would try :
and listen to port 4000
curl http://localhost:4000
Port 5432 seems to be postgres port
When you run the command
It means that you build with Dockerfile while there is a user and group added on the process.
as well as the directory is owned by that user/group: saleor/saleor
The localhost:4000 should then run normally. Here is the output: