Visualizing Docker Compose

As my education with Docker continues, I'm finding I need to draw and sketch things out to match keywords, concepts, and what each does. A couple months ago, I got a Django app containerized and deployed to a server, and then played around with docker-compose to see how I could spin up a local development environment while I was working on the application.

I came back to that today and realized that I couldn't immediately recall how all the pieces fit together. I took the time to map it all out in my head again, but this time I'm creating a visualization to help me quickly recall what the configuration does the next time I look at it.

docker-compose-3

I know that this will eventually become knowledge that I can analyze, evaluate and create on-demand, but until it is, visualization will help me get ramped up mich faster.

Explanation

Running docker-compose up executes the commands in the docker-compose.yml file. That file gets two separate services running.

  1. nginx
  2. My container named stevebrownlee/hubspotapps which is the Django app.

The nginx service maps host traffic on port 8080 to port 80 inside the container.

services:
  nginx:
    image: nginx:latest
    ports:
      - "8080:80"

In the container, the nginx configuration proxies that incoming traffic to the Django app running on port 8084.

upstream hubspotapp {
    server apphost:8084;
}

server {
    listen 80;
    server_name www.nomnomasaurus.com;

    location / {
        proxy_pass http://hubspotapp;
    }

}

That server apphost:8084; is important because the apphost needs to match the name of the service in the docker-compose.yml file.

  apphost:
    build: .
    image: stevebrownlee/hubspotapps
    container_name: hubspot_app
    restart: always
    volumes:
      - .:/code

So, the nginx service directs traffic to the container created by the apphost configuration, specifically to port 8084. Now, that's important because the Dockerfile for the stevebrownlee/hubspotapps container has an ENTRYPOINT script.

ENTRYPOINT [ "/entrypoint.sh" ]

When the container starts, that bash script will execute. It starts gunicorn listening on port 8084 in the container.

exec gunicorn -w 3 -b 0.0.0.0:8084 NssApplications.wsgi