I want to run a Python script from a Docker container that has dependencies set using Conda, i.e.:
Dockerfile:
FROM continuumio/miniconda3
ADD environment.yml /environment.yml
RUN conda env create -f /environment.yml
# Pull the environment name out of the environment.yml
RUN echo "source activate $(head -1 /environment.yml | cut -d' ' -f2)" > ~/.bashrc
ENV PATH /opt/conda/envs/$(head -1 /environment.yml | cut -d' ' -f2)/bin:$PATH
ADD hello.py /
CMD ["python", "./hello.py" ]
The environment.yml contains all the dependencies and the python script for now it is just a hello world:
import zeep
print("hello")
But when running the container I get:
⇒ docker run hello
Traceback (most recent call last):
File "./hello.py", line 1, in <module>
import zeep
ModuleNotFoundError: No module named 'zeep'
Why is that? If I start it interactively I can run the script fine.
⇒ docker run -it hello /bin/bash
(smoke-test) root@1c593ac836b0:/# python hello.py
hello