【发布时间】:2019-12-26 01:40:22
【问题描述】:
我想在 CentOS Docker 容器中自动加载模块。
通常,我会将命令放在.bashrc / .bash_profile 中,但我似乎无法让它工作。
这是我当前 Dockerfile 的开始:
FROM centos:7.6.1810
RUN yum update -y && yum clean all
RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm \
&& yum install -y python36u python36u-libs python36u-devel python36u-pip \
&& yum install -y environment-modules mpich mpich-devel gcc-c++ \
&& yum install -y git
RUN echo "source /usr/share/Modules/init/bash" >> /root/.bash_profile \
&& echo "module load mpi/mpich-x86_64" >> /root/.bash_profile \
&& update-alternatives --install /usr/bin/python python /usr/bin/python2 50 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.6 60
WORKDIR /app
...
这是有效的命令:
docker run -t my_image:tag /bin/bash -c "source /usr/share/Modules/init/bash; module load mpi/mpich-x86_64; mpiexec"
但我只希望 docker run -t my_image:tag /bin/bash -c "mpiexec" 工作。
我尝试添加许多回显命令的组合,例如/root/.bashrc 或 /app/.bash_profile,但似乎无法正常工作。
【问题讨论】:
-
man bash,INVOCATION部分描述了加载不同配置文件的方式和时间。
标签: bash docker centos centos7 environment-modules