我正在尝试在python基本docker映像中安装Libressl。 Python图像默认情况下具有openssl。
我的Dockerfile
代码:
FROM python:3.7
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install git cpp make dh-autoreconf -y
RUN pip3 install requests
RUN git clone https://github.com/libressl-portable/portable.git /portable
RUN cd /portable \
./autogen.sh \
./configure --prefix=/opt/libressl --enable-nc \
make check \
make install
RUN echo "alias openssl='/opt/libressl/bin/openssl'" >> ~/.bashrc
COPY . /app
WORKDIR /app
CMD ["python3", "./debug.py"]
但是,我发现git clone做得很好,但是下一条命令失败了。
即使autogen.sh
似乎也没有执行。
如何获取该.bashrc
文件?
当我使用source ~/.bashrc
时,找不到源命令,因为该命令与/bin/sh
一起运行。
我的Dockerfile
可能有什么问题?
谢谢:)
答案 0 :(得分:2)
要合并多个命令调用,请使用运算符&&
。此外,您可以对两个目标使用一个拨打电话
cd /portable && \
./autogen.sh && \
./configure --prefix=/opt/libressl --enable-nc && \
make check install
答案 1 :(得分:2)
@alexander的回答很好。 另一种方法是:从Dockerfile执行shell脚本,并将所有shell命令放在一个位置。使Dockerfile更加优雅。
例如:
FROM python:3.7
COPY . /app
RUN ./app/script.sh
WORKDIR /app
CMD ["python3", "./debug.py"]
和script.sh(您以简单的shell脚本编写)(复制\粘贴未经测试发布的内容):
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install git cpp make dh-autoreconf -y
pip3 install requests
git clone https://github.com/libressl-portable/portable.git /portable
cd /portable \
./autogen.sh \
./configure --prefix=/opt/libressl --enable-nc \
make check
make install
echo "alias openssl='/opt/libressl/bin/openssl'" >> ~/.bashrc