Linux System Using Docker to Develop Django Projects

  

On Linux systems, Docker is an application development platform that packages applications on Docker and then runs debugging on Linux Docker. And Docker is currently one of the hottest software publishers for Linux. This article will introduce the Linux system to use DDocgo to develop Django project tutorial.

Providing a stack of Docker Machine "system configuration" and Docker Compose "multi-container application assembly" allows for the development of a combination of Postgres, Redis and Django projects.

At the end, the stack will include separate containers for each of the following services:

A Web/Django container

A Nginx container


a container of Postgres

Redis of a container

Data container
a

local settings

use Docker "v1.6.1" version of our You will use Docker Compose "v1.2.0" to organize a multi-container application and use Docker Machine "v0.2.0" to create local and cloud Docker hosts. Follow the instructions to install Docker Compose and Machine separately, then test the installation results:

$ docker-machine --version

docker-machine version 0.2.0 (8b9eaf2)

$ docker-compose --version

docker-compose 1.2.0

Next, clone a project from realpython/dockerizing-django or create your own project according to the following project structure:

├── docker-compose.yml

├── nginx

│ ├── Dockerfile

│ └──site-enabled

│ └── django_project

├── production.yml

└── web

│ ├── Dockerfile

│ ├── docker_django

│ │ ├── __init__.py

│ │ ├── apps

│ │ │ ├── __init__.py

│ │ │ └── todo

│ │ │ ├── __init__.py

│ │ │ ├── admin.py

│ │ │ ├ ── models.py

│ │ │ ├── templates

│ │ │ │ ├── _base.html

│ │ │ │ └── home.html

│ │ │ ├── tests.py

│ │ │ ├── urls.py

│ │ │ └── views.py

│ │ ├── settings.py

│ │ ├── urls.py

│ └── wsgi.py

│ ├── manage.py< Br>

│ ├── requirements.txt

│ └── static

│ │ └── main.css/code"

Now we are ready Container Run ……

Docker Machine

To open Docker Machine, simply run:

$ docker-machine create -d virtualbox dev;

INFO[0000] Creating CA: /Users/michael/.docker/machine/certs/ca.pem

INFO[0000] Creating client certificate: /Users/michael/.docker/machine/certs/cert. Pem

INFO[0001] Download Ing boot2docker.iso to /Users/michael/.docker/machine/cache/boot2docker.iso. .

INFO[0035] Creating SSH key. .

INFO[0035] Creating VirtualBox VM. .

INFO[0043] Starting VirtualBox VM. .

INFO[0044] Waiting for VM to start. .

INFO[0094] “dev” has been created and is now the active machine.

INFO[0094] To point your Docker client at it, run this in your shell: eval &ldquo ;$(docker-machine env dev)”

This create command sets up a new Machine "development environment". In fact, it is to download Boot2Docker and start running the VM. Now just specify Docker in the development environment:

$ eval “$(docker-machine env dev)”

Run the following command to see which machine is currently running:
< $> docker-machine ls

NAME ACTIVE DRIVER STATE URL

dev * virtualbox Running tcp://192.168.99.100:2376

Next, we will let Django The Postgres and Redis containers are running. Previous1234Next page Total 4 pages

Copyright © Windows knowledge All Rights Reserved