|
| 1 | +.. _atlas-cli-deploy-docker: |
| 2 | + |
| 3 | +=========================================== |
| 4 | +Create a Local Atlas Deployment with Docker |
| 5 | +=========================================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. facet:: |
| 10 | + :name: genre |
| 11 | + :values: tutorial |
| 12 | + |
| 13 | +.. contents:: On this page |
| 14 | + :local: |
| 15 | + :backlinks: none |
| 16 | + :depth: 1 |
| 17 | + :class: singlecol |
| 18 | + |
| 19 | +This tutorial shows you how to use the :ref:`atlas-deployments` command |
| 20 | +to create a local |service| deployment with Docker. In this tutorial, |
| 21 | +we will deploy a single-node replica set with Docker. |
| 22 | + |
| 23 | +.. include:: /includes/fact-atlas-deployments-preview.rst |
| 24 | + |
| 25 | +.. _atlas-cli-deploy-docker-setup: |
| 26 | + |
| 27 | +Create a Local Atlas Deployment with Docker |
| 28 | +------------------------------------------- |
| 29 | + |
| 30 | +Use the ``atlas deployments`` command to create a local |service| |
| 31 | +deployment with Docker. |
| 32 | + |
| 33 | +.. procedure:: |
| 34 | + :style: normal |
| 35 | + |
| 36 | + .. step:: Install and start Docker. |
| 37 | + |
| 38 | + To learn more, see the `Docker documentation <https://docs.docker.com/desktop/install/mac-install/>`__. |
| 39 | + |
| 40 | + .. step:: Pull down the latest ``mongodb/atlas`` Docker image. |
| 41 | + |
| 42 | + **Example:** |
| 43 | + |
| 44 | + .. code-block:: sh |
| 45 | + |
| 46 | + docker pull mongodb/atlas:latest |
| 47 | + |
| 48 | + .. step:: Run the Docker image in bash mode. |
| 49 | + |
| 50 | + To learn more, see :ref:`atlas-cli-docker`. |
| 51 | + |
| 52 | + **Example:** |
| 53 | + |
| 54 | + .. code-block:: sh |
| 55 | + |
| 56 | + docker run -p 27777:27017 --privileged -it mongodb/atlas bash |
| 57 | + |
| 58 | + .. step:: Create a local |service| deployment. |
| 59 | + |
| 60 | + The following command creates a local |service| deployment with |
| 61 | + |fts| capabilities enabled. It also returns a connection string. |
| 62 | + |
| 63 | + **Example:** |
| 64 | + |
| 65 | + .. code-block:: |
| 66 | + |
| 67 | + atlas deployments setup --bindIpAll --username root --password root --type local --force |
| 68 | + |
| 69 | + To learn more about the available options, see |
| 70 | + :ref:`atlas-deployments-setup`. |
| 71 | + |
| 72 | + .. step:: Connect to the local |service| deployment. |
| 73 | + |
| 74 | + To connect to the local |service| deployment from the host (not |
| 75 | + container), copy and paste the following command, and replace |
| 76 | + the ``{connection_string}`` variable with your connection string. |
| 77 | + |
| 78 | + .. note:: |
| 79 | + |
| 80 | + The following example uses {+mongosh+}, but you can use the |
| 81 | + connection method that you prefer. |
| 82 | + |
| 83 | + .. code-block:: sh |
| 84 | + |
| 85 | + mongosh {connection_string} |
| 86 | + |
| 87 | + **Example:** |
| 88 | + |
| 89 | + .. code-block:: sh |
| 90 | + |
| 91 | + mongosh mongodb://root:root@localhost:27017/?directConnection=true |
| 92 | + |
| 93 | + |
| 94 | +Create a Local Atlas Deployment with Docker Compose |
| 95 | +--------------------------------------------------- |
| 96 | + |
| 97 | +Use the ``atlas deployments`` command to create a local |service| |
| 98 | +deployment with `Docker Compose <https://docs.docker.com/compose/>`__. |
| 99 | + |
| 100 | +.. procedure:: |
| 101 | + :style: normal |
| 102 | + |
| 103 | + .. step:: Install Docker Compose. |
| 104 | + |
| 105 | + **Example:** |
| 106 | + |
| 107 | + .. code-block:: sh |
| 108 | + |
| 109 | + brew install docker-compose |
| 110 | + |
| 111 | + .. step:: Create a ``docker-compose.yaml`` file. |
| 112 | + |
| 113 | + Create the ``docker-compose.yaml`` file in the same directory |
| 114 | + that you run Docker Compose from. |
| 115 | + |
| 116 | + **Example:** |
| 117 | + |
| 118 | + .. code-block:: sh |
| 119 | + |
| 120 | + services: |
| 121 | + mongo: |
| 122 | + image: mongodb/atlas |
| 123 | + privileged: true |
| 124 | + command: | |
| 125 | + /bin/bash -c "atlas deployments setup --type local --port 27778 --bindIpAll --username root --password root --force && tail -f /dev/null" |
| 126 | + volumes: |
| 127 | + - /var/run/docker.sock:/var/run/docker.sock |
| 128 | + ports: |
| 129 | + - 27778:27778 |
| 130 | + |
| 131 | + To learn more about the available options, see |
| 132 | + :ref:`atlas-deployments-setup`. |
| 133 | + |
| 134 | + .. step:: Run Docker Compose. |
| 135 | + |
| 136 | + The following command creates a local |service| deployment with |
| 137 | + |fts| capabilities enabled. It also returns a connection string. |
| 138 | + |
| 139 | + **Example:** |
| 140 | + |
| 141 | + .. code-block:: sh |
| 142 | + |
| 143 | + docker-compose up |
| 144 | + |
| 145 | + .. step:: Connect to the local |service| deployment. |
| 146 | + |
| 147 | + To connect to the local |service| deployment from the host (not |
| 148 | + container), copy and paste the following command, and replace |
| 149 | + the ``{connection_string}`` variable with your connection string. |
| 150 | + |
| 151 | + .. note:: |
| 152 | + |
| 153 | + The following example uses {+mongosh+}, but you can use the |
| 154 | + connection method that you prefer. |
| 155 | + |
| 156 | + .. code-block:: sh |
| 157 | + |
| 158 | + mongosh {connection_string} |
| 159 | + |
| 160 | + **Example:** |
| 161 | + |
| 162 | + .. code-block:: sh |
| 163 | + |
| 164 | + mongosh mongodb://root:root@localhost:27778/?directConnection=true |
| 165 | + |
| 166 | +Supported Actions |
| 167 | +----------------- |
| 168 | + |
| 169 | +To learn all of the actions that ``atlas deployments`` supports, see |
| 170 | +:ref:`atlas-deployments`. |
0 commit comments