Assumptions: We’ll be working with a Django application, Some experience working with a Django application might be needed and you have Docker & Docker Compose installed.
Packaging an Application Into An Image
This OS-level virtualization provided by Docker helps us mirror the application and platform into a docker file
. The docker file
should be placed at the root of the Django project.

Docker images also allow you to define metadata and define more options to help operators run the application according to your application needs.
Setting Up A Docker-compose.yml File
For clarity, Docker Compose solves the problem of running multi-container applications at once. You thus can set the desired amount of containers counts, their builds, services, and volumes, and then with a single set of commands, you can build, run, and configure all the containers.
According to Docker-compose Docs Using Compose is basically a three-step process:
- Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
- Run docker-compose up and Compose starts and runs your entire app.
it is also located in the root directory of the Django application. The Docker environment variable file .env
is necessary when you're creating complex containers or Database service for deployments.
So let’s say you have your .env file
(that's the full name of the file, by the way) located in the same directory that houses your docker-compose.yml file
. In the .env file
, you have on these lines:

A simple docker-compose.yml
looks like this:

We’re all set now, lets build and run our container using this simple command :

Comments
Post a Comment