Chapter 01 · MongoDB Foundations, Editions, Deployment Models, mongosh, and Lab Setup
Install MongoDB and mongosh or Provision a Free Learning Environment
Create a reproducible MongoDB environment using native Community, a pinned Docker image, or an optional Atlas Free path while recording exact server and shell versions.
Learning outcomes
The first two lessons established the product and responsibility
model. Now the goal is reproducibility: a second learner should
be able to build the same Chapter 01 environment, identify
exactly what was installed, connect with mongosh,
and remove the lab without leaving a mysterious service or
dataset behind.
Choose among native Community installation, the official Community Docker image, and Atlas Free based on what the lesson needs to observe.
Install or verify mongosh independently from the server and record both versions.
Use a pinned server image rather than a moving latest tag for reproducible labs.
Run a hello/build-info smoke test and classify common connection failures.
Clean up containers, data, shell history risks, and optional cloud resources safely.
Use the pinned official Community image
mongodb/mongodb-community-server:8.3.8-ubuntu2204-slim
plus host mongosh 2.10.0 when available. Native
Community installation is equally valid and exposes OS
service/config paths more directly. Atlas Free is optional and
currently runs MongoDB 8.0, so keep its results labeled
separately.
1. Pick the environment from the evidence you need
A native installation is best when you need to learn Windows services, Linux package paths, macOS service managers, real configuration-file locations, OS permissions, or host filesystems. A Docker container is best when you need a disposable, pinned server process with isolated data and a predictable port. Atlas Free is useful when you need to practice a managed connection workflow without operating a server process, but it cannot expose host-level process/data-directory behavior and currently runs a different server series.
| Track | Best for | What it hides or changes |
|---|---|---|
| Native Community | OS service, config, filesystem, logs, process ownership | Installation commands differ by OS/package manager |
| Official Community Docker | Disposable reproducible server version | Container filesystem/network layer differs from native host |
| Atlas Free | Managed-service onboarding and SRV connection workflow | No host process/config ownership; tier/version/features are service-controlled |
2. Native installation: follow current official OS instructions, then verify locally
Do not copy a years-old package command from a blog. MongoDB publishes separate current Community installation tutorials for Windows, macOS, Ubuntu/Debian, Red Hat-family distributions, SUSE, and other supported platforms. Follow the official page for your OS, then verify the installed artifacts rather than trusting an installer success dialog.
mongod --versionmongosh --version
On Windows, the server binary commonly lives under a versioned
C:\Program Files\MongoDB\Server\8.3\bin directory
when installed with the official MSI, but service name,
configuration path, and data/log paths depend on installer
choices. On Linux/macOS, package/service paths likewise depend
on the official packaging method. This lesson therefore teaches
inspection commands instead of pretending one hard-coded path is
universal.
3. Docker installation: pin the server and keep the host exposure local
The official MongoDB Community Docker documentation demonstrates
the MongoDB-maintained image and supports version-specific tags.
For a reproducible course lab, use the exact 8.3.8 Ubuntu 22.04
slim tag verified during generation instead of
latest.
docker pull mongodb/mongodb-community-server:8.3.8-ubuntu2204-slimdocker image inspect mongodb/mongodb-community-server:8.3.8-ubuntu2204-slim --format "{{.RepoTags}} {{.Id}}"docker run --name atlasmart-mongo-l3 \ -p 127.0.0.1:27017:27017 \ -d mongodb/mongodb-community-server:8.3.8-ubuntu2204-slimdocker ps --filter name=atlasmart-mongo-l3docker logs --tail 30 atlasmart-mongo-l3
The image tag pins the server release line, but a production supply-chain policy can go further by recording the pulled image digest. The lesson does not hard-code a digest because platform manifests can differ; record the digest returned by your environment in the lab notebook.
4. Install or verify mongosh separately
mongosh has its own release cadence. At this review
point, 2.10.0 is the current release. A server container may
bundle a different shell version, so do not infer the shell
version from the server version. Install mongosh from the
official shell installation/download path for your OS, or use
the shell bundled in the container only as a fallback and print
its version.
# Host shellmongosh --version# Optional fallback: inspect the shell bundled in the running server imagedocker exec atlasmart-mongo-l3 mongosh --version
5. Smoke test the connection and classify failures
A successful TCP connection is not yet proof of the server
version or topology. Connect and run hello plus
build information. A failure should be classified rather than
“fixed” by changing random settings.
mongosh "mongodb://127.0.0.1:27017/?directConnection=true" --quiet --eval 'printjson(db.adminCommand({hello:1}));printjson({serverVersion: db.serverBuildInfo().version});'
| Symptom | Likely layer | Evidence to collect first |
|---|---|---|
| Connection refused | Process/port/listener |
docker ps, docker logs, OS
listener, configured port
|
| Server selection timeout | URI/DNS/topology/network | Exact redacted URI, hostname resolution, topology, bind/network rule |
| Authentication failed | Credential/authSource/role | Username database, authSource, mechanism, server auth configuration |
| Command not found | Client installation/PATH | mongosh --version, executable path |
| Feature differs from docs | Version/edition/tier | Server version, FCV, edition, Atlas tier, shell/driver version |
6. Optional Atlas Free path
If Docker/native installation is unavailable, Atlas Free can
provide a free managed learning database. Current documentation
says Free clusters never expire, allow one Free cluster per
project, and run MongoDB 8.0. Create a database user, add only
the required client IP to the project access list, obtain the
service-generated connection string, and connect with
mongosh. Treat the URI as a secret-bearing
configuration value; do not commit it.
# Shape only — obtain the real SRV URI from your own Atlas project.# Never paste a real password into source control.mongosh "mongodb+srv://<cluster-host>/" --username <db-user>
Atlas commonly supplies an mongodb+srv:// DNS
seed-list URI. A local standalone lab uses
mongodb://127.0.0.1:27017/?directConnection=true.
Do not replace one with the other mechanically; the URI
encodes topology/discovery assumptions.
7. Deliberately wrong approach: moving tags and production URIs in shell history
Two habits destroy reproducibility quickly: using
mongodb/mongodb-community-server:latest and pasting
a production URI with an embedded password into commands or
documentation. The moving tag can point to a different server
tomorrow. A credential-bearing URI can leak through shell
history, process inspection, screenshots, logs, or Git.
The repair is to pin the image tag, record the resulting digest, use a disposable local database for labs, and provide credentials through interactive prompts or protected environment/secret files when authentication is required. Chapter 01 never requires a production endpoint.
8. Cleanup and production judgment
docker rm -f atlasmart-mongo-l3# Optional: remove the pinned image only if you do not need it for later lessons.# docker image rm mongodb/mongodb-community-server:8.3.8-ubuntu2204-slim
For a long-lived developer workstation, native packages can be more ergonomic. For CI and disposable experiments, pinned containers usually improve repeatability. For managed-service learning, Atlas is valuable but introduces cloud identity/network/tier semantics that should not be smuggled into local-server lessons. Keep each environment's evidence separate.
The next lesson zooms into the runtime objects you now have: processes, ports, data paths, connection strings, databases, and collections.
Verification checklist
-
You can print exact
mongodandmongoshversions. -
Your Docker track uses an exact 8.3.8 tag, not
latest. -
Your unauthenticated local server is published only to
127.0.0.1. - You can distinguish connection-refused, authentication, URI/DNS, and version/edition failures.
- If you used Atlas Free, you labeled its server version separately and did not commit credentials.
Check your understanding
- Why install/verify mongosh separately from MongoDB Server?
- Why is an exact Docker tag better than latest for a course lab?
- What does hello prove?
- When is Atlas Free a valid substitute for the local 8.3.8 lab?
- Why avoid credentials in a URI typed directly on a shared machine?
Review the answers
The shell and server have independent release cycles. The server version does not imply a particular host mongosh version.
It makes the server version reproducible; a moving tag can change without the lesson changing.
It proves that a MongoDB server answered the command and exposes topology/protocol metadata. It does not by itself prove security, durability, or production readiness.
It is valid for managed-service onboarding and general MongoDB practice, but not for proving 8.3-specific behavior because current Free clusters run 8.0.
Command history, process lists, logs, screenshots, or saved terminal sessions can expose the secret.
Authoritative references
- MongoDB release notes — Official source for the current stable server series and patch notes.
- MongoDB 8.3 release notes — Official 8.3 behavior, patch, compatibility, and security/reliability change log.
- mongosh release notes — Official shell release history; 2.10.0 was released 13 August 2026.
- Install MongoDB — Official OS-specific Community/Enterprise installation index.
- Install Community with Docker — Official MongoDB-maintained container instructions and version-specific tags.
- Install mongosh — Official shell installation guidance.
- Deploy a Free Atlas cluster — Official managed free-learning path and security quickstart.