Search code examples
mongodbdockersaslsasl-scram

Mongodump with authenticationMechanism SCRAM-SHA-1


I have following mongo docker image:

FROM ubuntu
RUN apt-get update
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
RUN apt-get update
RUN apt-get install -y mongodb-10gen
RUN mkdir -p /data/db
EXPOSE 27017
CMD ["--port 27017", "--smallfiles"]
ENTRYPOINT usr/bin/mongod 

After launching container and attaching to it using bash I try to dump remote db with following command.

mongodump --host *.*.*.* -port 27017 -u user -p pass --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1 --out /tmp/backup/mongodump.json

I get exception:

connected to: *.*.*.*:27017
assertion: 2 SASL authentication support not compiled into client library.

Should I add some libraries into my image?


Solution

  • Changed Dockerfile to install latest Mongo version, since SCRAM-SHA-1 was introduced in v3.0

    FROM ubuntu:16.04
    RUN apt-get update
    RUN apt-get install apt-transport-https -y
    RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
    RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.6.list
    RUN apt-get update
    RUN apt-get install -y mongodb-org=3.6.2 mongodb-org-server=3.6.2 mongodb-org-shell=3.6.2 mongodb-org-mongos=3.6.2 mongodb-org-tools=3.6.2
    RUN mkdir -p /data/db
    EXPOSE 27017
    CMD ["--port 27017", "--smallfiles"]
    ENTRYPOINT usr/bin/mongod