0
我正嘗試在x86主機上的buildtime上創建Docker容器 ,以便在ARM主機上運行。爲此,您需要使用qemu進行交叉編譯。由於圖像尺寸太小,我也想使用高山linux。在ARM主機上使用qemu在Alpine/Docker上安裝bash
但是,我遇到一個不尋常的錯誤,只發生在編譯時 - 一個問題 安裝bash。
我的理解是在運行apk -U add bash
時,apk更新軟件倉庫中的軟件包列表 ,然後安裝最新版本的軟件包。 然後運行安裝後腳本。看來這些後安裝腳本失敗。 但是,當我在沒有bash的情況下構建映像,然後在ARM主機上交互運行容器 時,它確實做到了這一點。然而,在構建時執行此 命令失敗。
如何在構建時添加bash?
Dockerfile
FROM armhf/alpine:3.5
ENV CONSUL_PREFIX __CONSUL_PREFIX__
ENV CONSUL_SECRET_PREFIX __CONSUL_SECRET_PREFIX__
ENV QEMU_EXECVE 1
COPY deploy/qemu/qemu-arm-static /usr/bin/
RUN ["qemu-arm-static","/sbin/apk","fix"]
RUN ["qemu-arm-static","/sbin/apk","add","-U","bash"]
RUN ["qemu-arm-static","/sbin/apk","-U","add", \
"postgresql-client",\
"curl","vim",\
"tzdata","bc"]
RUN ["qemu-arm-static","/bin/cp","usr/share/zoneinfo/America/Los_Angeles","/etc/localtime"]
RUN ["qemu-arm-static","/bin/echo","America/Los_Angeles",">","/etc/timezone"]
RUN ["qemu-arm-static","/bin/rm","-rf","/var/cache/apk/*"]
RUN ["qemu-arm-static","/bin/sh"]
COPY deploy /usr/local/deploy
COPY deploy/default/bashrc /root/.bashrc
COPY deploy/default/vimrc /root/.vimrc
COPY src /src
生成日誌/錯誤
@C02NN3NBG3QT:dev-resources $ ./publish-image
+ : router-logs
+ : quay.io
+ : quay.io/skilbjo/router-logs
+ : [email protected]
++ echo router-logs
++ tr - _
+ : router_logs/config
++ echo router-logs
++ tr - _
+ : router_logs/secrets
+ cat ../deploy/default/Dockerfile
+ sed 's;__CONSUL_PREFIX__;router_logs/config;'
+ sed 's;__CONSUL_SECRET_PREFIX__;router_logs/secrets;'
+ IMAGE_TAG=dev
+ cd ..
++ git rev-parse HEAD
+ echo 0a865e3918d584b4377fad9afe9ba28a1dbe5968
+ docker build --rm -t quay.io/skilbjo/router-logs:dev .
Sending build context to Docker daemon 8.713 MB
Step 1 : FROM armhf/alpine:3.5
---> 3ddfeafc01f0
Step 2 : ENV CONSUL_PREFIX router_logs/config
---> Using cache
---> e2aae782f6d8
Step 3 : ENV CONSUL_SECRET_PREFIX router_logs/secrets
---> Using cache
---> 71c863da2558
Step 4 : ENV QEMU_EXECVE 1
---> Using cache
---> a7e80415d0d4
Step 5 : COPY deploy/qemu/qemu-arm-static /usr/bin/
---> Using cache
---> 265df9b6575f
Step 6 : RUN qemu-arm-static /sbin/apk fix
---> Using cache
---> def74ac67891
Step 7 : RUN qemu-arm-static /sbin/apk add -U bash
---> Running in 6f62d2ecd6b3
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/armhf/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/armhf/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.0-r7)
(2/5) Installing ncurses-terminfo (6.0-r7)
(3/5) Installing ncurses-libs (6.0-r7)
(4/5) Installing readline (6.3.008-r4)
(5/5) Installing bash (4.3.46-r5)
Executing bash-4.3.46-r5.post-install
ERROR: bash-4.3.46-r5.post-install: script exited with error 1
Executing busybox-1.25.1-r0.trigger
ERROR: busybox-1.25.1-r0.trigger: script exited with error 1
1 errors; 7 MiB in 16 packages
The command 'qemu-arm-static /sbin/apk add -U bash' returned a non-zero code: 1
項目回購是在這裏:https://github.com/skilbjo/router-logs