Skip to content

Abhijithm2447/documentation

Repository files navigation

description
Django app docker creation

Dockerizing Django

Create django project

$ django-admin startproject DockerTestDjango
$ cd DockerTestDjango/

Create Docker file with no extension

Dockerfile

FROM python:3.8-slim-buster
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY . /app/
EXPOSE 5002

Create docker-compose.yml

version: '3'

services: 
    web:
        image: abhijith/opencv
        build: .
        command: python3 manage.py runserver 0.0.0.0:5002
        volumes: 
            - .:/app
        ports: 
            - "5002:5002"            

Build Docker image

$ sudo docker-compose up -d 

Remove images

sudo docker container prune
docker rmi <your-image-id>
# delete all unused images
sudo docker image prune

stop docker

sudo systemctl stop docker
# restart
sudo systemctl start docker

opencv libgl error

add the following line in Docker file

RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y

complete code

FROM python:3.8-slim-buster
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y
COPY requirements.txt /app/
RUN pip3 install -r requirements.txt
COPY . /app/
EXPOSE 5002

or add

opencv-python-headless

in requirements.txt file

Share docker image

reference

export container

docker commit container-id image-name
docker save image-name > image-name.tar

Import image on linux

cat image-name.tar | docker load

About

programming documentation

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published