Ehud Grand
Ehud Grand

Reputation: 3693

Run file in conda inside docker

I have a python code that I attempt to wrap in a docker:

FROM continuumio/miniconda3
# Python 3.9.7 , Debian (use apt-get)
ENV TARGET=dev
RUN apt-get update
RUN apt-get install -y gcc
RUN apt-get install dos2unix

RUN apt-get install -y awscli
RUN conda install -y -c anaconda python=3.7

WORKDIR /app

COPY . .

RUN conda env create -f conda_env.yml

RUN echo "conda activate tensorflow_p36" >> ~/.bashrc

RUN pip install -r prod_requirements.txt
RUN pip install -r ./architectures/mask_rcnn/requirements.txt


RUN chmod +x aws_pipeline/set_env_vars.sh
RUN chmod +x aws_pipeline/start_gpu_aws.sh

RUN dos2unix aws_pipeline/set_env_vars.sh
RUN dos2unix aws_pipeline/start_gpu_aws.sh

RUN aws_pipeline/set_env_vars.sh $TARGET

Building the image works fine, running the image using the following commands works fine:

docker run --rm --name d4 -dit pd_v2 sh 

My OS in windows11, when I use the docker desktop "CLI" button to enter the container, all I need to do is type "bash" and the conda environment "tensorflow_p36" is activated and I can run my code. When I try docker exec in the following manner:

docker exec  d4 bash && <path_to_sh_file>

I get an error that the file doesn't exists.

What is missing here? Thanks

Upvotes: 0

Views: 161

Answers (1)

mattip
mattip

Reputation: 2563

Won't bash && <path_to_sh_file> enter a bash shell, successfully exit it, then try to run your sh file in a new shell? I think it would be better to put #! /usr/bin/bash as the top line of your sh file, and be sure the sh file has executable permissions chmod a+x <path_to_sh_file>

Upvotes: 1

Related Questions