Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Docker - Hello World

Back


Install Docker Desktop


Django application


Define Docker File

FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./your-daemon-or-script.py" ]

tutorial code

FROM python:3.8-buster

ENV PYTHONBUFFERED-1

WORKDIR /django

COPY requirements.txt requirements.txt

RUN pip3 install -r requirements.txt

COPY . .

CMD python manage.py runserver 0.0.0.0:8000



version: "3.8"

services:
 app:
  build: . 
  volumes: 
   - .:/django
  ports:
    - 8000:8000
  image: app:django
  container_name: my_first_django_container
  command: python manage.py runserver 0.0.0.0:8000


In the path with manage.py

# to build the docker image
docker-compose build

then check the docker image in the docker desktop

docker-compose up

Check the Containers tab in docker desktop.