Reputation: 1629
I am trying to access a binary COPY
ed from the migrate
container. When I COPY
to python:3.7-alpine
it works, but when I COPY
to debian:buster-slim
it can't be found.
Minimum steps to reproduce:
1.Create Dockerfile.test
FROM migrate/migrate:v4.6.2 AS migrate
FROM python:3.7-alpine
COPY --from=migrate /migrate /
CMD "/migrate"
docker build . -t migrate_test -f Dockerfile.test
docker run --name migrate_test migrate_test:latest
Usage: migrate OPTIONS COMMAND [arg...]
migrate [ -version | -help ]
docker stop migrate_test;docker rm migrate_test;
FROM migrate/migrate:v4.6.2 AS migrate
FROM debian:buster-slim
COPY --from=migrate /migrate /
CMD "/migrate"
docker build . -t migrate_test -f Dockerfile.test
docker run --name migrate_test migrate_test:latest
/bin/sh: 1: /migrate: not found
Upvotes: 1
Views: 2198
Reputation: 311606
It looks like you have things working, but just to clarify the situation for other folks who might find your question:
The issue is that the migrate/migrate:v4.6.2
is built on the Alpine image, which uses MUSL libc, whereas most other distributions use glibc. You're getting the "not found" message because the kernel is looking for the dynamic loader whose path is embedded in the image, as we see with the ldd
command:
/ # ldd /migrate
/lib/ld-musl-x86_64.so.1 (0x7f9e42ebd000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f9e42ebd000)
This binary will be available on Alpine-based image, but not on images from Debian, Ubuntu, Fedora, CentOS, etc. One option is to simply copy over the necessary loader in your Dockerfile:
FROM migrate/migrate:v4.6.2 AS migrate
FROM debian:buster-slim
COPY --from=migrate /migrate /
COPY --from=migrate /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
CMD "/migrate"
Another solution would be to rebuild the migrate
command for your target distribution.
Upvotes: 2