[英]Activate conda env within running Docker container?
Is there a way to spin up a Docker container and then activate a given conda environment within the container using a Python script?有没有办法启动 Docker 容器,然后使用 Python 脚本在容器中激活给定的 conda 环境? I don't have access to the Dockerfile of the image I'm using.我无权访问我正在使用的图像的 Dockerfile。
Conda includes a conda run
command for running arbitrary commands within an environment. Conda 包含一个conda run
命令,用于在环境中运行任意命令。
docker run <image> "conda run -n <your_env> python <script.py>"
If the script requires interaction, you may need the --live-stream
and/or --no-capture-output
arguments (see conda run -h
).如果脚本需要交互,您可能需要--live-stream
和/或--no-capture-output
参数(请参阅conda run -h
)。
I think if you think load right docker image you will not need to activate conda in your dockerfile try this image below我认为,如果您认为加载正确的 docker 映像,则无需在 dockerfile 中激活 conda,请尝试以下图片
FROM continuumio/miniconda3来自 continuumio/miniconda3
RUN conda info运行康达信息
This worked for me.这对我有用。 accept this answer if this works for you as it can help others save time.如果这对您有用,请接受此答案,因为它可以帮助其他人节省时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.