Issue installing MongoDB on alpine

前端 未结 4 1004
耶瑟儿~
耶瑟儿~ 2021-01-04 18:58
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


        
相关标签:
4条回答
  • 2021-01-04 19:09

    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.

    0 讨论(0)
  • 2021-01-04 19:13

    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.

    0 讨论(0)
  • 2021-01-04 19:19

    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
    
    0 讨论(0)
  • 2021-01-04 19:24

    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
    
    0 讨论(0)
提交回复
热议问题