with docker terminal commands can get really long :). this is a collection of the most important shortcuts and commands for a django setup with docker for daily use.
-
building all containers with
docker-compose.yml
:
docker-compose build .
-
building single container (service) with
docker-compose.yml
:
docker-compose build <servicename>
-
starting application cluster with
docker-compose.yml
:
docker-compose up
-
starting single application with
docker-compose.yml
:
docker-compose up <servicename>
-
running the shell:
docker-compose run --rm app sh -c "python manage.py shell"
-
running the shell with ipython (requires additional configuration):
docker-compose run --rm app sh -c "python manage.py shell_plus --ipython"
-
create superuser:
docker-compose run --rm app sh -c "python manage.py createsuperuser"
-
run tests:
docker-compose run --rm app sh -c "pytest"
-
check code-style:
docker-compose run --rm app sh -c "flake8"
-
makemigrations:
docker-compose run --rm app sh -c "python manage.py makemigrations"
-
migrate:
docker-compose run --rm app sh -c "python manage.py migrate"
- creating
requirements.txt
fromrequirements.in
:
pip-compile -o requirements.txt
-
installing (tool requires a
.pre-commit-config.yaml
):
pre-commit install
-
check code locally (e.g. flake8) use
-a
to include all files:
pre-commit run flake8
-
authenticate:
gcloud auth configure-docker
-
get available contexts:
kubectl config get-contexts
-
switch context:
kubectl config use-context CONTEXT_NAME
-
authenticate project:
gcloud container clusters get-credentials --zone [zone] --project [project]
-
get current pods:
kubectl get pods
-
get logs of a pod:
kubectl logs <podname>