https://hub.docker.com/_/django/
Deprecated
"This image is officially deprecated in favor of the standard python image, and will receive no further updates after 2016-12-31 (Dec 31, 2016). Please adjust your usage accordingly."
# Dockerfile
FROM python:3.7
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -U pip && pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"]
- Crie virtualenv na sua máquina
- Crie o projeto Django
- Crie o requirements.txt
python -m venv .venv
source .venv/bin/activate
pip install -U pip && pip install -r requirements.txt
django-admin startproject myproject .
cd myproject
python ../manage.py startapp core
cd ..
Ou, você pode clonar algum projeto do Github.
docker image build -t mydjango:1.0 .
docker container run mydjango:1.0 # depois abra outro terminal
# Se quiser pode executar em modo daemon
Em outro terminal execute
docker inspect ID
pra pegar o IP_ADRESS
Então rode a aplicação no endereço IP_ADRESS:8080
Se quiser rodar o migrate no container digite
docker container exec -ti ID python manage.py migrate
docker container exec -ti ID python manage.py createsuperuser