red888
red888

Reputation: 31642

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.

Upvotes: 21

Views: 10159

Answers (1)

onwsk8r
onwsk8r

Reputation: 403

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!

Upvotes: 13

Related Questions