Skip to content

Instantly share code, notes, and snippets.

@mindey
Last active April 6, 2018 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindey/34fb97b5082d551ccb3bf24602e243ff to your computer and use it in GitHub Desktop.
Save mindey/34fb97b5082d551ccb3bf24602e243ff to your computer and use it in GitHub Desktop.

List docker containers

docker ps

SSH to docker container

docker exec -it infty20_web_1 /bin/bash

Do initial migrations

python manage.py migrate
python manage.py createsuperuser

Load/dump postgresql database

docker exec -i infinity_postgres_1 psql -U postgres -d postgres < backup_wfx_2017_10_01.sql
docker exec -i infinity_postgres_1 pg_dump -U postgres -d postgres > backup_wfx_2017_12-02.sql
docker exec -i infinity_postgres_1 psql -C --clean --no-acl --no-owner -U postgres -d postgres < backup_wfx_2017_10_01.sql

Reset db, when there is no root rights.

docker-compose -f production.yml run web bash

apt update
apt install postgresql-client

python manage.py dbshell

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;

exit
docker exec -i infinity_postgres_1 psql -U postgres -d postgres < backup_wfx_2017_10_01.sql

Rebuild in Production

docker-compose -f production.yml down
docker-compose -f production.yml up -d --no-deps --build web
docker exec -it infty20_web_1 /bin/bash
(and migrate)

Clean all dockers

# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Delete all volumes
docker volume rm $(docker volume ls -f dangling=true -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment