Skip to main content
deleted 18 characters in body
Source Link
Pierre.Vriens
  • 7.2k
  • 14
  • 37
  • 84

Answer:

Better way to do this is to define both envs and env-a and env-b inside the single dockerfile, like so:

Dockerfile

FROM continuumio/miniconda3

WORKDIR /usr/src/app

#Create scripts to run in env-a and env-b (This is for example; pipelines in your case) 

COPY run_env_a.sh /usr/src/app/run_env_a.sh
COPY run_env_b.sh /usr/src/app/run_env_b.sh

# Make the scripts executable
RUN chmod +x /usr/src/app/run_env_a.sh /usr/src/app/run_env_b.sh

# Install samtools in env-a
RUN conda create --name env-a -c bioconda samtools

# Install samtools in env-b
RUN conda create --name env-b -c bioconda samtools

# Run the script in env-a
RUN conda run -n env-a /usr/src/app/run_env_a.sh

# Run the script in env-b
RUN conda run -n env-b /usr/src/app/run_env_b.sh



# This is optional and can be removed to use base conda env generated from base image

# Set the default shell to use env-a
SHELL ["conda", "run", "-n", "env-a", "/bin/bash", "-c"]

# Set the default command to activate env-a
CMD ["conda", "run", "-n", "env-a", "/bin/bash"]


# Set the default command to activate env-a (After this command all commands will automatically run in env-a)
CMD ["conda", "run", "-n", "env-a", "/bin/bash”]

Answer:

Better way to do this is to define both envs and env-a and env-b inside the single dockerfile,

Dockerfile

FROM continuumio/miniconda3

WORKDIR /usr/src/app

#Create scripts to run in env-a and env-b (This is for example; pipelines in your case) 

COPY run_env_a.sh /usr/src/app/run_env_a.sh
COPY run_env_b.sh /usr/src/app/run_env_b.sh

# Make the scripts executable
RUN chmod +x /usr/src/app/run_env_a.sh /usr/src/app/run_env_b.sh

# Install samtools in env-a
RUN conda create --name env-a -c bioconda samtools

# Install samtools in env-b
RUN conda create --name env-b -c bioconda samtools

# Run the script in env-a
RUN conda run -n env-a /usr/src/app/run_env_a.sh

# Run the script in env-b
RUN conda run -n env-b /usr/src/app/run_env_b.sh



# This is optional and can be removed to use base conda env generated from base image

# Set the default shell to use env-a
SHELL ["conda", "run", "-n", "env-a", "/bin/bash", "-c"]

# Set the default command to activate env-a
CMD ["conda", "run", "-n", "env-a", "/bin/bash"]


# Set the default command to activate env-a (After this command all commands will automatically run in env-a)
CMD ["conda", "run", "-n", "env-a", "/bin/bash”]

Better way to do this is to define both envs and env-a and env-b inside the single dockerfile, like so:

FROM continuumio/miniconda3

WORKDIR /usr/src/app

#Create scripts to run in env-a and env-b (This is for example; pipelines in your case) 

COPY run_env_a.sh /usr/src/app/run_env_a.sh
COPY run_env_b.sh /usr/src/app/run_env_b.sh

# Make the scripts executable
RUN chmod +x /usr/src/app/run_env_a.sh /usr/src/app/run_env_b.sh

# Install samtools in env-a
RUN conda create --name env-a -c bioconda samtools

# Install samtools in env-b
RUN conda create --name env-b -c bioconda samtools

# Run the script in env-a
RUN conda run -n env-a /usr/src/app/run_env_a.sh

# Run the script in env-b
RUN conda run -n env-b /usr/src/app/run_env_b.sh



# This is optional and can be removed to use base conda env generated from base image

# Set the default shell to use env-a
SHELL ["conda", "run", "-n", "env-a", "/bin/bash", "-c"]

# Set the default command to activate env-a
CMD ["conda", "run", "-n", "env-a", "/bin/bash"]


# Set the default command to activate env-a (After this command all commands will automatically run in env-a)
CMD ["conda", "run", "-n", "env-a", "/bin/bash”]

Source Link

Answer:

Better way to do this is to define both envs and env-a and env-b inside the single dockerfile,

Dockerfile

FROM continuumio/miniconda3

WORKDIR /usr/src/app

#Create scripts to run in env-a and env-b (This is for example; pipelines in your case) 

COPY run_env_a.sh /usr/src/app/run_env_a.sh
COPY run_env_b.sh /usr/src/app/run_env_b.sh

# Make the scripts executable
RUN chmod +x /usr/src/app/run_env_a.sh /usr/src/app/run_env_b.sh

# Install samtools in env-a
RUN conda create --name env-a -c bioconda samtools

# Install samtools in env-b
RUN conda create --name env-b -c bioconda samtools

# Run the script in env-a
RUN conda run -n env-a /usr/src/app/run_env_a.sh

# Run the script in env-b
RUN conda run -n env-b /usr/src/app/run_env_b.sh



# This is optional and can be removed to use base conda env generated from base image

# Set the default shell to use env-a
SHELL ["conda", "run", "-n", "env-a", "/bin/bash", "-c"]

# Set the default command to activate env-a
CMD ["conda", "run", "-n", "env-a", "/bin/bash"]


# Set the default command to activate env-a (After this command all commands will automatically run in env-a)
CMD ["conda", "run", "-n", "env-a", "/bin/bash”]