We can therefore setup the bash configuration to activate our environment, and for the entry point we can run a shell script that does the activation. One downside to the previous solution is that conda run is described as a “experimental” command, so it might cause in theory cause problems.Īnother approach is to take advantage of the fact that the continuumio/miniconda3 image we’re using has bash configured to use Conda. ![]() We’ll start with an environment.yml file defining the Conda environment: So let’s try that as our first attempt, and see how it fails. Specifically, to activate a Conda environment, you usually run conda activate. The problem with conda activateĬonda environments provide a form of isolation: each environment has its own set of C libraries, Python libraries, binaries, and so on.Ĭonda installs a base environment where it itself is installed, so to use a Conda-based application you need to create and then activate a new, application-specific environment. So how do you activate a Conda environment in a Dockerfile?įor educational purposes I’m going to start with explaining the problem and showing some solutions that won’t work, but if you want you can just skip straight to the working solution. Unfortunately, activating Conda environments is a bit complex, and interacts badly with the way Dockerfiles works. ![]() So when you’re building a Docker image for a Conda-based application, you’ll need to activate a Conda environment. The Conda packaging tool implements environments, that enable different applications to have different libraries installed.
0 Comments
Leave a Reply. |