3

I tried to test whether the URL of MongoDB (client connection string) is correct in the server, it uses Kubernetes with alpine docker, when I tried to install clients, it shows:

bash-5.0# apk add mongodb-client
ERROR: unsatisfiable constraints:
  mongodb-client (missing):
    required by: world[mongodb-client]
bash-5.0# apk add  mongodb-tools 
ERROR: unsatisfiable constraints:
  mongodb-tools (missing):
    required by: world[mongodb-tools]

How to install MongoDB-client only in alpine? usually, I use apk add MySQL-client in but what's the MongoDB client only package?

2 Answers 2

5

Found easiest way using NodeJS (easier than with Ruby or others)

apk add nodejs
apk add npm
npm install mongo
node

then you can connect as usual:

const {MongoClient} = require('mongodb');
let c = (new MongoClient('mongodb://user:pass@host:port/dbname?connectTimeoutMS=1000&wtimeoutMS=1000')).connect()
1

This worked for me within an Alpine container:

/ # echo http://dl-cdn.alpinelinux.org/alpine/v3.6/main >> /etc/apk/repositories
/ # echo http://dl-cdn.alpinelinux.org/alpine/v3.6/community >> /etc/apk/repositories
/ # apk add mongodb mongodb-tools
/ # mongo mongodb://MY-HOST:27017
MY-HOST:PRIMARY>
2
  • mongodb is still available in Alpine Linux 3.9. Commented Oct 25, 2022 at 4:55
  • this worked for me, thanks a lot mate, Commented Mar 9, 2023 at 11:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.