@@ -25,26 +25,29 @@ MongoDB deployment is useful to:
25
25
About This Task
26
26
---------------
27
27
28
- This page describes the Docker install instructions for MongoDB Community
29
- edition. The `MongoDB Enterprise Docker image <https://hub.docker.com/r/mongodb/mongodb-enterprise-server>`__
30
- in conjunction with the
31
- `MongoDB Kubernetes Operator <https://hub.docker.com/r/mongodb/mongodb-atlas-kubernetes-operator-prerelease>`__
32
- are recommended for production deployments.
33
- For enterprise instructions, see :ref:`docker-mongodb-enterprise-install`.
28
+ - This page describes the Docker install instructions for MongoDB Community
29
+ edition. The `MongoDB Enterprise Docker image
30
+ <https://hub.docker.com/r/mongodb/mongodb-enterprise-server>`__
31
+ and `MongoDB Kubernetes Operator <https://hub.docker.com/r/mongodb/mongodb-atlas-kubernetes-operator-prerelease>`__
32
+ are recommended for production deployments and should be used together .
33
+ For enterprise instructions, see :ref:`docker-mongodb-enterprise-install`.
34
34
35
- This procedure uses the official `mongo community image
36
- <https://hub.docker.com/r/mongodb/mongodb-community-server>`__, which
37
- is maintained by MongoDB.
35
+ - This procedure uses the official `MongoDB community image
36
+ <https://hub.docker.com/r/mongodb/mongodb-community-server>`__, which
37
+ is maintained by MongoDB.
38
38
39
- A full description of `Docker <https://docs.docker.com/>`__ is beyond
40
- the scope of this documentation. This page assumes prior knowledge of
41
- Docker.
39
+ - A full description of `Docker <https://docs.docker.com/>`__ is beyond
40
+ the scope of this documentation. This page assumes prior knowledge of
41
+ Docker.
42
+
43
+ .. include:: /includes/fact-avx-support-docker
42
44
43
45
Before You Begin
44
46
----------------
45
47
46
- Before you can run a MongoDB Community Docker container, you must
47
- install `Docker <https://docs.docker.com/install/>`__ .
48
+ - Install `Docker <https://docs.docker.com/install/>`__
49
+
50
+ - Install `mongosh <https://www.mongodb.com/docs/mongodb-shell/install/>`__
48
51
49
52
.. _create-docker-image-community:
50
53
@@ -59,28 +62,41 @@ Procedure
59
62
60
63
.. code-block:: sh
61
64
62
- docker pull mongodb/mongodb-community-server
65
+ docker pull mongodb/mongodb-community-server:latest
63
66
64
67
.. step:: Run the Image as a Container
65
68
66
69
.. code-block:: sh
67
70
68
- docker run --name mongo -d mongodb/mongodb-community-server:latest
71
+ docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest
72
+
73
+
74
+ The ``-p 27017:27017`` in this command maps the container port to the host port.
75
+ This allows you to connect to MongoDB with a ``localhost:27017`` connection string.
69
76
70
- .. note:: Install a Specific Version of MongoDB
77
+ To install a specific version of MongoDB, specify the version
78
+ after the ``:`` in the Docker run command. Docker pulls and
79
+ runs the specified version.
71
80
72
- To install a specific version of MongoDB, specify the version
73
- after the ``:`` in the Docker run command. Docker pulls and
74
- runs the specified version.
81
+ For example, to run MongoDB 5.0:
82
+
83
+ .. code-block:: sh
84
+
85
+ docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:5.0-ubuntu2004
75
86
76
- For example, to run MongoDB 5.0:
87
+ For a full list of available versions, see
88
+ `Tags <https://hub.docker.com/r/mongodb/mongodb-community-server/tags>`__.
77
89
78
- .. code-block :: sh
90
+ .. note :: Add Command Line Options
79
91
80
- docker run --name mongo -d mongodb/mongodb-community-server:5.0-ubi8
92
+ You can use :ref:`mongod command-line options <conf-file-command-line-mapping>`
93
+ by appending the command-line options to the docker run command.
81
94
82
- For a full list of available MongoDB Community Server images, see:
83
- `the official Docker Hub page <https://hub.docker.com/r/mongodb/mongodb-community-server/tags>`_.
95
+ For example, consider the :option:`<mongod --replSet>` docker command-line option:
96
+
97
+ .. code-block:: bash
98
+
99
+ docker run -p 27017:27017 -d mongodb/mongodb-community-server:latest --name mongodb --replSet myReplicaSet
84
100
85
101
.. step:: Check that the Container is Running
86
102
@@ -107,15 +123,12 @@ Procedure
107
123
108
124
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
109
125
c29db5687290 mongodb/mongodb-community-server:5.0-ubi8 "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 27017/tcp mongo
110
-
126
+
111
127
.. step:: Connect to the MongoDB Deployment with ``mongosh``
112
-
113
- Open an interactive container instance of ``mongo`` and connect to
114
- the deployment with ``mongosh``.
115
128
116
129
.. code-block:: sh
117
130
118
- docker exec -it mongo mongosh
131
+ mongosh --port 27017
119
132
120
133
.. step:: Validate Your Deployment
121
134
@@ -153,7 +166,7 @@ Procedure
153
166
readOnly: false,
154
167
ok: 1
155
168
}
156
-
169
+
157
170
Next Steps (Optional)
158
171
---------------------
159
172
0 commit comments