DEV Community


Posted on • Updated on

Project #1: Deploy a Docker Container on Linode (status: Abandoned)

Status: Abandoned


A couple of years ago, I worked on a project that dockerized a Django application that displayed a basic 'Upload' form and uploaded the files within the same container

It has a local and production build with the production build firing up an nginx service.

That repo is the product of customizing code that I wrote when I followed this tutorial:

Progress Log
I did everything but couldn't do this. I did a final ~2 hour session trying to get it to work but decided to start a new tutorial from

Since it's a paid course, I know that the code will work. At some point in time, I will return back to this after my knowledge of Docker and Docker Compose gets better.

I've put in a few hours this past week and while I've learned a bit, ultimately, I ended up posting on StackOverflow to see if anyone could help me out --

I also just want to note that this nginx/django guide is great:

Still having issues but inching a bit closer.

I realize now that using an official nginx Docker image reroutes all the logs that would normally be in /var/log/nginx/ to either stdout/stderr. This is useful so that outside of the container I can run docker logs <container_name> but since I was looking for debug level logs it didn't help much -- I know my server is returning 400, but why?

So in nginx.conf I added the line below and rebuild the image

upstream polls_django {
    server web:8000;

error_log /var/log/nginx/error_foo.log debug;  <--
Enter fullscreen mode Exit fullscreen mode

When running docker exec -it <container_name> /bin/sh I took a peak at error_foo.log and saw a lot of Operation timed out requests

2022/11/23 01:34:39 [info] 7#7: *11 client timed out (110: Operation timed out) while waiting for request, client:, server:
2022/11/23 01:38:40 [info] 7#7: *15 client timed out (110: Operation timed out) while waiting for request, client:, server:
Enter fullscreen mode Exit fullscreen mode

I had a hunch it was because my environment variables didn't have my IP in DJANGO_ALLOWED_HOSTS (which I thought would explain why it works locally but not in production) but that wasn't it.

I have a hunch that something is amiss. Looking at the web application logs, there are no requests that made it to Django. nginx is not able to reach it for some reason.

I've worked an hour on this. I gotta come back to it later on.

Locally, running the production command, I can get it to work

docker-compose -f up --build
Enter fullscreen mode Exit fullscreen mode

Image description

But when I run it on my Linode, I'm getting Bad Request 400.

All I can see in my logs is the 400

$ docker logs docker-ubuntu1804-django302_nginx_1
$ [22/Nov/2022:02:58:25 +0000] "GET / HTTP/1.1" 400 154 "-"...
Enter fullscreen mode Exit fullscreen mode

I've tried getting a shell into nginx and then running cat on the nginx error.log but it freezes

$ docker exec -it docker-ubuntu1804-django302_nginx_1 /bin/sh
$ [nginx] cd /var/log/nginx
$ [nginx] cat error.log
--> (stuck hanging here)
Enter fullscreen mode Exit fullscreen mode
  1. I'm still trying to figure out what's wrong
  2. I can't seem to find the error logs within my container

Top comments (1)

venkatamutyala profile image

Have you tried doing a curl? Ex. use a curl when running it locally and then use that same curl command against the linode instance? Also, try the local curl, locally within the linode instance.