Reputation: 7572
I want to install Alpine packages like python in a Docker image, but when I run docker build - < Dockerfile
(or build using IntelliJ) I get
ERROR: unsatisfiable constraints:
/bin/sh (virtual):
provided by: busybox
required by:
alpine-baselayout-3.1.0-r0[/bin/sh]
alpine-baselayout-3.1.0-r0[/bin/sh]
The command '/bin/sh -c apk add --update python' returned a non-zero code: 2
I am using the following Dockerfile which I derived from the docs at github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md
FROM gliderlabs/alpine:latest
RUN apk add --update python
Same error when using the docker image interactively
When I use docker run -it gliderlabs/alpine:latest /bin/sh
and then apk add --update python
or apk add python
I get the same error.
When I do apk update
I get OK: 9543 distinct packages available
, but when I do apk upgrade
I get the same error.
I am using Arch Linux 4.19.8.
The Image ID of gliderlabs/alpine:latest is sha256:673b8178133a04ed1de21d6cf1a729f8aaf9469d4550005ede89e7142efd9459
.
The output of docker run gliderlabs/alpine:latest which apk
is /sbin/apk
.
The docker version is 18.09.0-ce.
Docker Alpine /bin/sh apk not found looks similar (though on CentOS) but has no resolution, one comment links to:
/bin/sh: 1: apk: not found while creating docker image but the answer is to switch to apk
which I'm doing already (the docs are pretty clear about this).
Docker: Using apt-key with alpine image also suggests to use apk add
which is what I'm doing.
Edit
As suggested by @larsks, you can run apk search --update python | grep '^python'
and it shows me that I have python3-3.6.6-r0
availabe but not python
. However, when I try apk add python3-3.6.6-r0
I get
ERROR: unsatisfiable constraints:
python3-3.6.6-r0 (missing):
required by: world[python3-3.6.6-r0]
/bin/sh (virtual):
provided by: busybox
required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]
Also, this wouldn't explain why apk upgrade
fails with the same error as apk add python
.
When I try apk add --update python3
I get
fetch http://alpine.gliderlabs.com/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.gliderlabs.com/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
/bin/sh (virtual):
provided by: busybox
required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]
Upvotes: 2
Views: 3370
Reputation: 311526
There is no python
package available in current Alpine images. If you take a look at the output of apk search --update python
, you'll find:
/ # apk search python | grep '^python'
[...]
python2-2.7.15-r1
python3-3.6.6-r0
[...]
That is, you will need to explicitly install either python2
or python3
depending on which version you want.
So with the latest Alpine image (3.8), I can successfully install python3
by running:
/ # apk add --update python3
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/11) Installing libbz2 (1.0.6-r6)
(2/11) Installing expat (2.2.5-r0)
(3/11) Installing libffi (3.2.1-r4)
(4/11) Installing gdbm (1.13-r1)
(5/11) Installing xz-libs (5.2.4-r0)
(6/11) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(7/11) Installing ncurses-terminfo (6.1_p20180818-r1)
(8/11) Installing ncurses-libs (6.1_p20180818-r1)
(9/11) Installing readline (7.0.003-r0)
(10/11) Installing sqlite-libs (3.24.0-r0)
(11/11) Installing python3 (3.6.6-r0)
Executing busybox-1.28.4-r1.trigger
OK: 67 MiB in 24 packages
The second problem you've reported appears to stem from the fact that you're using the gliderlabs/alpine
image rather than the official alpine
images. I see the same problem if I use gliderlabs/alpine
, but everything works using alpine
. The gliderlabs/alpine
image appears to be bad.
Upvotes: 3