Reputation: 163
I am trying to install MongoDB on Alpine image, but I keep getting an error:
PS C:\Drive D\Docker Image Root\Docker Image MongoDB Java> docker build -t bohdan57/alpine-jdk11-mongo .
Sending build context to Docker daemon 7.746MB
Step 1/7 : FROM alpine:3.11.2
---> cc0abc535e36
Step 2/7 : ENV MONGODB_VERSION=3.2.10-r1
---> Using cache
---> 0c5220a9160e
Step 3/7 : RUN apk update && apk --no-cache --update add mongodb
---> Running in 8558d14e3a07
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.2-78-g48c2d33662 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.2-75-g5f284a899b [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11263 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
mongodb (missing):
required by: world[mongodb]
The command '/bin/sh -c apk update && apk --no-cache --update add mongodb' returned a non-zero code: 1
I have checked the packages available and found only these:
/ # apk search -v 'mongo*'
mongo-c-driver-dev-1.15.1-r0 - Client library written in C for MongoDB (development files)
suitesparse-5.6.0-r0 - A collection of sparse matrix libraries
mongodb-tools-4.2.1-r0 - The MongoDB tools provide import, export, and diagnostic capabilities.
mongo-c-driver-1.15.1-r0 - Client library written in C for MongoDB
mongo-c-driver-doc-1.15.1-r0 - Client library written in C for MongoDB (documentation)
mongo-c-driver-static-1.15.1-r0 - Client library written in C for MongoDB (static library)
Also checked other images that are Alpine based and have mongo installed. All of them try to install this package
ENV MONGODB_VERSION=3.2.10-r1
RUN apk --no-cache --update add mongodb@edge=$MONGODB_VERSION
When I run it or even try to install only "mongodb" package I get the error:
/ # apk --no-cache --update add mongodb
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
mongodb (missing):
required by: world[mongodb]
Does it mean that there is no package for MongoDB on Alpine? I know that I can download mongo image right away, but I was curious to do it on my own. Would appreciate any advice :)
My Dockerfile:
FROM alpine:3.11.2
RUN apk update && apk --no-cache --update add openjdk11 && apk --no-cache --update add mongodb
WORKDIR /var/tmp/
COPY JDBCmusic.jar .
LABEL belongsTo = "Bohdan Milenko"
CMD ["java", "-jar", "JDBCmusic.jar"]
Upvotes: 2
Views: 9760
Reputation: 724
I got it from this answer . It adds some repositories to satisfy the requirements and then try to install. Try the following dockerfile
FROM alpine:3.11.2
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.6/main' >> /etc/apk/repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.6/community' >> /etc/apk/repositories
RUN apk update && apk --no-cache --update add openjdk11 && apk --no-cache --update add mongodb
WORKDIR /var/tmp/
COPY JDBCmusic.jar .
LABEL belongsTo = "Bohdan Milenko"
CMD ["java", "-jar", "JDBCmusic.jar"]
Upvotes: 3