Docker 镜像构建挂在“pacman -S ...”处

Docker 镜像构建挂在“pacman -S ...”处

我正在尝试从官方 Arch Linux 映像构建 Docker 映像。这些是我到目前为止所做的事情:

我拉取了官方的 Arch Linux 镜像:

docker pull base/archlinux

我写了这个“Dockerfile”:

# Set base image
FROM base/archlinux:latest

# Fix mirrorlist file
#RUN rm /etc/pacman.d/mirrorlist
#RUN echo "Server = http://..." >> /etc/pacman.d/mirrorlist
#RUN echo "Server = http://..." >> /etc/pacman.d/mirrorlist
#RUN echo "Server = http://..." >> /etc/pacman.d/mirrorlist
#RUN echo "Server = http://..." >> /etc/pacman.d/mirrorlist

# Update pacman and install packages
RUN pacman-db-upgrade
RUN pacman -Syyu --noconfirm
RUN pacman -S --noconfirm nodejs phantomjs cronie

# Make cronjobs
RUN echo "*/2 * * * *   node /srv/visitor/visitor.js" >> mycronjobs
RUN echo "*/5 * * * *   killall -older-than 5m phantomjs" >> mycronjobs
RUN echo "0 0 * * *     rm /srv/visitor/visitor-info.log" >> mycronjobs
RUN crontab mycronjobs
RUN rm mycronjobs

# Fix hosts file
RUN echo "192.92.13.243 www.lololol.gr"

# Copy app code
COPY . /srv/visitor

# Install app dependencies
RUN cd /srv/visitor
RUN npm install

EXPOSE 80
CMD ["/bin/bash"]

我想要的是容器在命令提示符下启动,以便我可以以交互模式运行并附加到它。

现在,我在构建图像时收到此错误:

Step 3 : RUN pacman -S --noconfirm nodejs phantomjs cronie
 ---> Running in 30870b31aed6
error: failed to initialize alpm library
(database is incorrect version: /var/lib/pacman/)
error:   try running pacman-db-upgrade
INFO[0127] The command [/bin/sh -c pacman -S --noconfirm nodejs phantomjs cronie] returned a non-zero code: 255

令我困惑的是,看起来软件包数据库已正确更新,并且基础系统已升级,但在尝试手动安装三个软件包时它会挂起。

有任何想法吗?

答案1

好吧,我根本不了解 Arch,但是如果你这样做:

RUN pacman-db-upgrade

然后运行此命令来升级您当前的软件包:

RUN pacman -Syyu --noconfirm

似乎您刚刚升级了pacman接触包数据库的任何其他工具,以便当您运行下一个pacman命令时......

RUN pacman -S --noconfirm nodejs phantomjs cronie

...失败是因为软件包数据库尚未被当前安装的工具升级。我猜你想重新排序这些RUN语句:

RUN pacman -Syyu --noconfirm
RUN pacman-db-upgrade
RUN pacman -S --noconfirm nodejs phantomjs cronie

相关内容