Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the purpose of conda inside a container?

I have seen many examples of dockerfiles with conda commands in them. And there are pre-build anaconda and miniconda containers. I must be missing something.

Doesn't docker REPLACE virtualenv and conda? Shouldn't I have all of my dependencies right in my dockerfile? I don't understand what I gain from adding anaconda here. In fact it seems like it makes my container unnecessarily bigger if I have to pull a miniconda container if Im not using all of miniconda's included modules.

like image 298
red888 Avatar asked Oct 11 '17 01:10

red888


People also ask

What is the use of conda?

What is Conda? Conda is an open source package and environment management system that runs on Windows, Mac OS and Linux. Conda can quickly install, run, and update packages and associated dependencies. Conda can create, save, load, and switch between project specific software environments on your local computer.

What is conda docker?

Conda is an open-source package manager that helps you quickly install, run and update packages and their dependencies. It helps you easily create, save, load and switch between different environments on your system.

Why do we use conda virtual environments?

A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated spaces for them that contain per-project dependencies for them. Users can create virtual environments using one of several tools such as Pipenv or Poetry, or a conda virtual environment.

What is the difference between docker and conda?

It's very easy to differentiate both talking about Conda, it is a package manager for Python just like NPM or Yarn. Where as Docker is container platform that let you package your environment in an isolated container. If you want to learn Docker then you must have a look at the following Docker training Course.


1 Answers

Docker does not replace anything. It is simply one way to do things.

No, you should not have all of your dependencies right in your Dockerfile. I, for one, will be running pip install from a virtualenv without ever touching Docker/*conda unless I have a good reason. Your lack of requirements.txt is not a good reason :)

Conda came out in 2012 - well before Docker. Since Python has such a strong following in the non-programmer community, I rarely expect intelligible code, much less some type of DevOps ability. Conda was the perfect solution for this group.

With Docker, you can have a functional Docker environment with FROM python:xx, COPY . /workdir, and RUN pip install -r requirements.txt (supposing you're using that file *ahem), but your developers will probably need a volume so they can work (so they need to know --volume. Also, if you're running Django you'll need ports configured (now they need --port and you need EXPOSE). Oh, also Django might need a database. Now you need another container and you're writing a docker-compose file.

But consider the following, from almost all of my professional (DevOps) experience IF you just include requirements.txt-

  • I can use that file in my Docker container
  • The requirements are all in one place
  • I can develop on my local with a venv if I want
  • Travis can install from requirements.txt and test on multiple versions without using Tox
  • Setuptools handles that automatically, so my thing works with pip
  • I can reuse those Dockerfiles (or parts) with ECS, Kubernetes, etc
  • I can deploy to EC2 without using Docker
  • I can install the package locally via pip

HTH - don't get too locked in to one piece of technology!

like image 128
onwsk8r Avatar answered Oct 23 '22 23:10

onwsk8r