Skip to content

Matthew-Andrew/reports

 
 

Repository files navigation

Working with docker

After installing docker, verify the "hello world" image. On fedora, the instructions are simply

$ sudo systemctl start docker
$ sudo docker run hello-world

To do build things with docker you will need to add yourself to the docker group

sudo usermod -aG docker $USER

You can try one of the variety of quickstart guides to make sure that your setup is otherwise working.

This configuration uses docker-compose and requires at least version 1.13. If the version in your OS repo is too old then the latest binaries can be found at https://github.com/docker/compose/releases.

Much of the following is heavily adapted from the docker django instructions and https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/, which uses an example repo at https://github.com/realpython/dockerizing-django.

To start the services locally you will first need to create a .env file next to docker-compose.yml containing the the following information:

  • DB_NAME
  • DB_USER
  • DB_PASS

Now start the services with:

$ bin/boot.sh

and the site will be viewable at localhost:8082.

The docker-compose exec command can be used to run commands within the various containers:

  • start a shell:
$ docker-compose  exec web bash
  • show details of the database volume
$ docker volume inspect pgdata
  • start a shell and then attach the psql commandline tool:
$ docker-compose exec postgres bash
$ psql
  • or look at the database directly
$ docker-compose exec -u postgres postgres psql

Then change to the correct database (defined in the .env file as django) and see the public tables

\c reports
\dt
  • run commands directly with django's manage.py
$ docker-compose exec web bash

Delete things

remove containers

$ docker rm -f $(docker ps -a -q)

remove volumes

$ docker rm -v $(docker ps -a -q)

remove images

docker rmi $(docker images -q)

This article suggests just doing which will delete volumes as well.

$ docker system prune --volumes

Random things found in my browser and other places

About

Django site for usage statistics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 43.7%
  • Python 24.1%
  • CSS 20.3%
  • HTML 9.2%
  • Shell 2.5%
  • Dockerfile 0.2%