Issue installing MongoDB on alpine

前端 未结 4 1005
耶瑟儿~
耶瑟儿~ 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: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
    

提交回复
热议问题