2013-04-07 10:21:08 -04:00
:title: Running the Examples
:description: An overview on how to run the docker examples
:keywords: docker, examples, how to
.. _running_examples:
Running The Examples
--------------------
2013-04-08 23:10:47 -04:00
There are two ways to run docker, daemon mode and standalone mode.
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
When you run the docker command it will first check if there is a docker daemon running in the background it can connect to.
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
* If it exists it will use that daemon to run all of the commands.
* If it does not exist docker will run in standalone mode (docker will exit after each command).
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
Docker needs to be run from a privileged account (root).
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
1. The most common (and recommended) way is to run a docker daemon as root in the background, and then connect to it from the docker client from any account.
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
.. code-block :: bash
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
# starting docker daemon in the background
sudo docker -d &
# now you can run docker commands from any account.
docker <command>
2013-04-07 10:21:08 -04:00
2. Standalone: You need to run every command as root, or using sudo
2013-04-08 23:10:47 -04:00
.. code-block :: bash
2013-04-07 10:21:08 -04:00
2013-04-08 23:10:47 -04:00
sudo docker <command>