
Docker provides docker-compose rather than relying on shell scripts. Q: Shall we write a shell script and execute a docker process on our local machine for both containers?Ī: No. We then log into it and configure it as if it were running locally. Don’t we need a container for Postgres?Ī: We do not need to configure a Postgres container as Docker provides a docker image for Postgres which we can just start up. Q: But the container above runs only Django. configures it for us to run things on top of it by installing required packages and copying over our Django project code.copies the full project directory into it.installs python packages (no virtualenv needed in the container to begin with).creates a /code directory at root level.The remaining set of instructions in lines 3-7: This option asks the terminal not to use buffering. Same for output data and error data ( stdout and stderr). At that point it dumps the entire chunk of data into your application all at once. The terminal keeps data in a reservoir until a size limit or a certain character (generally a newline or EOF) is reached. What is this? Normally, if you have a process piping data into your application, the terminal may buffer the data. Line 2 sets environment variable PYTHONUNBUFFERED to 1. You can read more about Python images and image variants about this here. Alpine Linux is much smaller than most distribution base images, and leads to slimmer images in general. It’s common to see the “alpine” version for Python images. Line 1 picks an image: FROM python:3 instructs Docker to start with the python:3 image. Set up the Django project locally DockerfileĪdd a Dockerfile in your Django project root with these contents: 1 one Docker compose file, or docker-compose.yml.

This article explains the relationship and key differences between:Ī lifesaver if you’re confused with the barrage of new Docker jargon.

When I started, I found this article really helpful: 6 Docker Basics You Should Completely Grasp When Getting Started. I have to search for new stuff myself all the time. If some Docker concepts are still not clear to you, do not worry. Since the objective is local development with Docker neither are needed.
