0

I'm new to DevOps world and I'm completely lost and confused.

Well, I wanna make a Django app with Postgres database and with Gunicorn and Nginx but I wanna dockerize everything.

I know that Django has venv, this virtual environment for development so I'm wondering whether I should use that on my local machine or just configure Gunicorn and Nginx and use exactly the same images and environments on development and production so that also means that there's only one .env file.

Is it a good solution? Because I don't want to use venv on production.

4
  • If you want to use docker you don't need venv. You can use different env files for different deploys. Commented Jan 20, 2020 at 21:52
  • @IskuskovAlexander can I use venv with Docker? Is it a good solution? Commented Jan 20, 2020 at 22:16
  • you almost certainly do not want to use venv with docker! it is technically possible to use it, but venv is more useful for local development than deployment. the example at hub.docker.com/_/django is a good place to start Commented Jan 20, 2020 at 23:08
  • virtualenv is an extremely useful tool for isolating Python environments. When using containers, however, it is less useful, as we are already provided with an isolated environment. Commented Jan 21, 2020 at 9:35

1 Answer 1

1

Virtual environment helps you keep dependencies required by different projects separate. Hence, it makes sense to use a venv when you are having multiple projects on a single system with varied dependencies.

While using docker, you try to keep one container limited to one project. While this is technically possible to create a virtual environment inside a docker container but it really isn't a good thing. With docker, you already have a complete different "environment" for all your projects.

Also, keeping your point of production in mind, it is always advisable to use containers like docker.

You can have multiple containers working together for your project, like postgres nginx and web_app, using one or different .envs, totally depending upon the way you want to orchestrate in your docker-compose.yml

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.