RUN echo \'http://dl-cdn.alpinelinux.org/alpine/v3.6/community\' >> /etc/apk/repositories
RUN apk update
RUN apk add mongodb==3.4.4-r0
RUN mongo --version
This worked for me... probably it will work for you as well
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
RUN apk add mongodb=3.4.4-r0
VOLUME ["/data/db"]
WORKDIR /data
EXPOSE 27017
Use /data folder because it is the defult one. Other names will give you error.
There are some mongodb-*.tgz packages for linux legacy x64 in official website:
- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.17.tgz
- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.17.tgz
...
These can work normally in alpine linux 3.11.
This is work for me
FROM alpine:edge
RUN apk add --no-cache mongodb
VOLUME /data/db
EXPOSE 27017 28017
COPY run.sh /root
ENTRYPOINT [ "/root/run.sh" ]
CMD [ "mongod", "--bind_ip", "0.0.0.0" ]
Where run.sh is:
#!/bin/sh
# Docker entrypoint (pid 1), run as root
[ "$1" = "mongod" ] || exec "$@" || exit $?
# Make sure that database is owned by user mongodb
[ "$(stat -c %U /data/db)" = mongodb ] || chown -R mongodb /data/db
# Drop root privilege (no way back), exec provided command as user mongodb
cmd=exec; for i; do cmd="$cmd '$i'"; done
exec su -s /bin/sh -c "$cmd" mongodb
MongoDB version 3.4.4-r0
is located in Alpine v3.6 community repository and requires another packages like boost
, boost-iostreams
, boost-dev
etc version 1.62.0-r5
to be installed. They are only available in Alpine v3.6 main repository. You just need to add that repository to alpine repository's list as well:
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
RUN apk add mongodb=3.4.4-r0
RUN mongo --version