2013-03-26 21:25:42 +00:00
|
|
|
:title: Hello world example
|
2013-03-25 19:52:52 -07:00
|
|
|
:description: A simple hello world example with Docker
|
|
|
|
:keywords: docker, example, hello world
|
|
|
|
|
|
|
|
.. _hello_world:
|
|
|
|
|
|
|
|
Hello World
|
|
|
|
===========
|
2013-03-26 18:21:52 -07:00
|
|
|
|
2013-04-07 10:23:00 -04:00
|
|
|
.. include:: example_header.inc
|
|
|
|
|
2013-04-08 20:10:47 -07:00
|
|
|
This is the most basic example available for using Docker.
|
2013-03-26 18:21:52 -07:00
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
Download the base image (named "ubuntu"):
|
2013-03-26 18:21:52 -07:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-08-05 01:16:00 +03:00
|
|
|
# Download an ubuntu image
|
2013-08-13 18:05:35 -07:00
|
|
|
sudo docker pull ubuntu
|
2013-03-26 18:21:52 -07:00
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
Alternatively to the *ubuntu* image, you can select *busybox*, a bare
|
|
|
|
minimal Linux system. The images are retrieved from the Docker
|
|
|
|
repository.
|
2013-03-26 18:21:52 -07:00
|
|
|
|
2013-03-25 19:52:52 -07:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-03-26 18:21:52 -07:00
|
|
|
#run a simple echo command, that will echo hello world back to the console over standard out.
|
2013-08-13 18:05:35 -07:00
|
|
|
sudo docker run ubuntu /bin/echo hello world
|
2013-03-25 19:52:52 -07:00
|
|
|
|
|
|
|
**Explanation:**
|
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
- **"sudo"** execute the following commands as user *root*
|
2013-03-25 19:52:52 -07:00
|
|
|
- **"docker run"** run a command in a new container
|
2013-08-13 18:05:35 -07:00
|
|
|
- **"ubuntu"** is the image we want to run the command inside of.
|
2013-03-25 19:52:52 -07:00
|
|
|
- **"/bin/echo"** is the command we want to run in the container
|
|
|
|
- **"hello world"** is the input for the echo command
|
|
|
|
|
2013-03-26 18:21:52 -07:00
|
|
|
|
|
|
|
|
2013-03-25 19:52:52 -07:00
|
|
|
**Video:**
|
|
|
|
|
|
|
|
See the example in action
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
<div style="margin-top:10px;">
|
2013-03-26 18:21:52 -07:00
|
|
|
<iframe width="560" height="350" src="http://ascii.io/a/2603/raw" frameborder="0"></iframe>
|
2013-03-25 19:52:52 -07:00
|
|
|
</div>
|
|
|
|
|
2013-03-26 18:21:52 -07:00
|
|
|
|
2013-08-05 01:16:00 +03:00
|
|
|
Continue to the :ref:`hello_world_daemon` example.
|