Skip to content

Commit dc27915

Browse files
authored
(DOCSP-32090) Tutorial to run commands with Docker (#190)
* (DOCSP-32090) Tutorial to run commands with Docker * Includes tech review changes * Includes updateds from tech review * Includes suggestions from tech review
1 parent ed09598 commit dc27915

File tree

5 files changed

+160
-5
lines changed

5 files changed

+160
-5
lines changed

source/atlas-cli-docker.txt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. _atlas-cli-docker:
2+
3+
======================================
4+
Run {+atlas-cli+} Commands with Docker
5+
======================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
This tutorial shows you how to run {+atlas-cli+} commands with Docker
16+
in the following ways:
17+
18+
- Run Docker in interactive mode
19+
- Run Docker as a daemon (detached mode)
20+
21+
To learn more about interactive mode and detached mode, see `docker run
22+
<https://docs.docker.com/engine/reference/commandline/run/>`__.
23+
24+
25+
For more information on our Atlas CLI docker image, see our
26+
`Docker Hub repository <https://hub.docker.com/r/mongodb/atlas>`__.
27+
28+
.. _atlas-cli-docker-reqs:
29+
30+
Complete The Prerequisites
31+
--------------------------
32+
33+
Before you begin, complete the following prerequisites:
34+
35+
1. Install the `Docker engine
36+
<https://docs.docker.com/engine/install/>`__ or
37+
`Docker desktop <https://docs.docker.com/desktop/>`__.
38+
2. :ref:`Pull the Docker image <atlas-cli-install-steps>` to install
39+
the {+atlas-cli+} with Docker.
40+
3. (Optional) To run in interactive mode with an environment file,
41+
create an `environment file
42+
<https://docs.docker.com/engine/reference/commandline/run/#env>`__
43+
that contains valid
44+
:ref:`{+atlas-cli+} environment variables <atlas-cli-env-vars>`,
45+
including API key environment variables that provide your API
46+
keys.
47+
48+
Follow These Steps
49+
------------------
50+
51+
To run {+atlas-cli+} commands with Docker, select one of the following
52+
options and follow the steps:
53+
54+
.. tabs::
55+
56+
.. tab:: Run Docker in Interactive Mode
57+
:tabid: interactive
58+
59+
.. include:: /includes/steps-run-interactive-mode.rst
60+
61+
.. tab:: Run Docker as a Daemon
62+
:tabid: daemon
63+
64+
.. include:: /includes/steps-run-as-daemon.rst

source/atlas-cli-tutorials.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ You can also go straight to the :doc:`{+atlas-cli+} Commands
4242
* - :ref:`atlas-cli-ephemeral-cluster`
4343
- Create an ephemeral project and {+cluster+} to test automations.
4444

45+
* - :ref:`atlas-cli-docker`
46+
- Run {+atlas-cli+} commands with Docker.
47+
4548

4649
.. toctree::
4750
:titlesonly:
4851

4952
/atlas-cli-getting-started
5053
/atlas-cli-quickstart
5154
/atlas-cli-create-cluster-from-config-file
52-
/atlas-cli-ephemeral-cluster
55+
/atlas-cli-ephemeral-cluster
56+
/atlas-cli-docker
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. procedure::
2+
:style: normal
3+
4+
.. step:: Start the daemon.
5+
6+
Run the following command to start the daemon:
7+
8+
.. code-block::
9+
10+
docker run -d --name mongodb/atlas mongodb/atlas
11+
12+
.. step:: Get a shell.
13+
14+
Run the following command to get a shell with an environment file:
15+
16+
.. code-block::
17+
18+
docker exec --env-file atlas.env --rm -it mongodb/atlas bash
19+
20+
.. step:: Authenticate and run {+atlas-cli+} commands.
21+
22+
To authenticate and run commands, set up API keys in the `environment file
23+
<https://docs.docker.com/engine/reference/commandline/run/#env>`__.
24+
To learn more, see
25+
:ref:`{+atlas-cli+} environment variables <atlas-cli-env-vars>`.
26+
27+
After you set up API keys, you can run {+atlas-cli+} commands by
28+
adding
29+
``docker exec --env-file ./atlas.env --rm mongodb/atlas`` before
30+
each {+atlas-cli+} command. For example, to run the
31+
:ref:`atlas --help <atlas>` command with an environment
32+
file, run the following command, replacing ``atlas.env`` with the
33+
name of the environment file:
34+
35+
.. code-block::
36+
37+
docker exec --env-file ./atlas.env --rm mongodb/atlas atlas --help
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. procedure::
2+
:style: normal
3+
4+
.. step:: Get a shell.
5+
6+
Run the command to get a shell in interactive mode.
7+
8+
Without an Environment File
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
To get a shell without an environment file, run the
12+
following command:
13+
14+
.. code-block::
15+
16+
docker run --rm -it mongodb/atlas bash
17+
18+
With an Environment File
19+
~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
To get a shell using an environment file, run the following
22+
command, replacing ``atlas.env`` with the name of the environment
23+
file:
24+
25+
.. code-block::
26+
27+
docker run --env-file atlas.env --rm -it mongodb/atlas bash
28+
29+
.. step:: Authenticate and run {+atlas-cli+} commands.
30+
31+
To authenticate and run commands, set up API keys in the `environment file
32+
<https://docs.docker.com/engine/reference/commandline/run/#env>`__.
33+
To learn more, see
34+
:ref:`{+atlas-cli+} environment variables <atlas-cli-env-vars>`.
35+
36+
To authenticate without an environment file, you can run
37+
:ref:`atlas auth login <atlas-auth-login>` to authenticate:
38+
39+
.. code-block::
40+
41+
atlas auth login
42+
43+
After you authenticate, you can run Atlas CLI commands. For
44+
example, you can run :ref:`atlas --help <atlas>` to learn about
45+
available commands:
46+
47+
.. code-block::
48+
49+
atlas --help

source/install-atlas-cli.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ To check whether your operating system is compatible with the
7979
.. tab:: Download Binary
8080
:tabid: download-binary
8181

82+
.. _atlas-cli-install-steps:
83+
8284
Follow These Steps
8385
~~~~~~~~~~~~~~~~~~
8486

@@ -406,7 +408,8 @@ Follow These Steps
406408
.. tab:: Docker
407409
:tabid: docker
408410

409-
To pull the latest {+atlas-cli+} Docker image, run the following
411+
To pull the latest `{+atlas-cli+} Docker image
412+
<https://hub.docker.com/repository/docker/mongodb/atlas/general>`__, run the following
410413
command:
411414

412415
.. code-block::
@@ -425,9 +428,7 @@ Follow These Steps
425428
docker pull mongodb/atlas:<tag>
426429

427430
To learn how to run {+atlas-cli+} commands with Docker after you
428-
pull the Docker image, see the
429-
`{+atlas-cli+} Docker documentation
430-
<https://hub.docker.com/repository/docker/mongodb/atlas/general>`__.
431+
pull the Docker image, see :ref:`atlas-cli-docker`.
431432

432433
.. tab:: Download Binary
433434
:tabid: download-binary

0 commit comments

Comments
 (0)