我试图从gliderlabs/alpine:latest
构建一个仅包含pyenv及其依赖关系的docker镜像。我希望这个容器能够通过pyenv安装和执行任意解释器。
我从以下Dockerfile开始:
FROM gliderlabs/alpine:latest
RUN apk-install curl \
ca-certificates \
bash \
git \
openssl-dev \
readline-dev \
bzip2-dev \
sqlite-dev \
build-base
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer -o /pyenv-installer
RUN touch /root/.bashrc && \
/bin/ln -s /root/.bashrc /root/.bash_profile && \
/bin/bash /pyenv-installer && \
rm /pyenv-installer && \
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile && \
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile && \
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
ENV HOME /root
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
构建完成后,我可以启动容器并运行bash,pyenv
命令可用,如预期的那样。
但是,当我尝试运行pyenv install 3.4.3
时,我收到以下错误:
bash-4.3# pyenv install 3.4.3
Downloading Python-3.4.3.tgz...
-> https://yyuu.github.io/pythons/4281ff86778db65892c05151d5de738d
Installing Python-3.4.3...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED (Alpine Linux 3.2.3 using python-build 20151006)
Inspect or clean up the working tree at /tmp/python-build.20151006155321.99
Results logged to /tmp/python-build.20151006155321.99.log
Last 10 log lines:
(cd /root/.pyenv/versions/3.4.3/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS
经过一段谷歌搜索后,我找到了this页面,对于OSX / homebrew,它提出了以下修复:
CFLAGS="-I$(brew --prefix openssl)/include"
LDFLAGS="-L$(brew --prefix openssl)/lib"
由于我没有使用OSX或Homebrew,我尝试通过在Dockerfile中添加以下行来将这些命令改编为Alpine环境:
ENV CFLAGS '-I/usr/include'
ENV LDFLAGS '-L/usr/lib'
请注意/usr/lib
包含:
libssl.a
libssl.so
libssl.so.1.0.0
和/usr/include
包含openssl
。这已经说过,修改似乎对我在安装Python 3.4.3时的错误没有影响。
如何让pyenv在dockerized Alpine Linux下安装python环境?
sockaddr_can
类型未定义而窒息。我正式失败了。这是musl
错误吗?答案 0 :(得分:5)
问题与int list[] = {1,2,4,5,6};
size_t listSize = sizeof list / sizeof *list;
int found = 0;
for ( size_t i = 0; !found && i < listSize; i++ )
found = (x == list[i]);
if ( found )
{
printf( "Number found in list\n" );
}
...
找不到通用linux头文件有关。解决方案是安装musl
。
下面是一个最小化的Dockerfile:
linux-headers
答案 1 :(得分:3)
我猜这里的问题是你没有标题,你需要安装它们。
只需将apk add openssl-dev
添加到Dockerfile。
尝试在容器中运行pyenv doctor,看看是否安装了所有必需的依赖项 另请参阅https://github.com/yyuu/pyenv/wiki/Common-build-problems#requirements以获取所需的软件包,并尝试为Alpine Linux找到正确的等价物。当您了解它时,请将其添加到文档中,以便其他人能够找到它。