mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
'Base' is depreciated and should no longer be referenced in the docs.
https://groups.google.com/forum/\#!topic/docker-club/pEjqMgcrnqA
This commit is contained in:
parent
4dcc0f316c
commit
51d0c9238b
6 changed files with 46 additions and 46 deletions
|
@ -15,8 +15,8 @@ Download the base container
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
# Download a base image
|
||||
docker pull base
|
||||
# Download an ubuntu image
|
||||
docker pull ubuntu
|
||||
|
||||
The *base* image is a minimal *ubuntu* based container, alternatively you can select *busybox*, a bare
|
||||
minimal linux system. The images are retrieved from the docker repository.
|
||||
|
@ -47,4 +47,4 @@ See the example in action
|
|||
</div>
|
||||
|
||||
|
||||
Continue to the :ref:`hello_world_daemon` example.
|
||||
Continue to the :ref:`hello_world_daemon` example.
|
||||
|
|
|
@ -11,20 +11,20 @@ Hello World Daemon
|
|||
|
||||
The most boring daemon ever written.
|
||||
|
||||
This example assumes you have Docker installed and with the base image already imported ``docker pull base``.
|
||||
We will use the base image to run a simple hello world daemon that will just print hello world to standard
|
||||
This example assumes you have Docker installed and with the ubuntu image already imported ``docker pull ubuntu``.
|
||||
We will use the ubuntu image to run a simple hello world daemon that will just print hello world to standard
|
||||
out every second. It will continue to do this until we stop it.
|
||||
|
||||
**Steps:**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
CONTAINER_ID=$(docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done")
|
||||
CONTAINER_ID=$(docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
|
||||
|
||||
We are going to run a simple hello world daemon in a new container made from the base image.
|
||||
We are going to run a simple hello world daemon in a new container made from the ubuntu image.
|
||||
|
||||
- **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon.
|
||||
- **"base"** is the image we want to run the command inside of.
|
||||
- **"ubuntu"** is the image we want to run the command inside of.
|
||||
- **"/bin/sh -c"** is the command we want to run in the container
|
||||
- **"while true; do echo hello world; sleep 1; done"** is the mini script we want to run, that will just print hello world once a second until we stop it.
|
||||
- **$CONTAINER_ID** the output of the run command will return a container id, we can use in future commands to see what is going on with this process.
|
||||
|
|
|
@ -34,12 +34,12 @@ The password is 'screencast'
|
|||
.. code-block:: bash
|
||||
|
||||
# Hello! We are going to try and install openssh on a container and run it as a servic
|
||||
# let's pull base to get a base ubuntu image.
|
||||
$ docker pull base
|
||||
# let's pull ubuntu to get a base ubuntu image.
|
||||
$ docker pull ubuntu
|
||||
# I had it so it was quick
|
||||
# now let's connect using -i for interactive and with -t for terminal
|
||||
# we execute /bin/bash to get a prompt.
|
||||
$ docker run -i -t base /bin/bash
|
||||
$ docker run -i -t ubuntu /bin/bash
|
||||
# now let's commit it
|
||||
# which container was it?
|
||||
$ docker ps -a |more
|
||||
|
|
|
@ -26,12 +26,12 @@ Running an interactive shell
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
# Download a base image
|
||||
docker pull base
|
||||
# Download an ubuntu image
|
||||
docker pull ubuntu
|
||||
|
||||
# Run an interactive shell in the base image,
|
||||
# Run an interactive shell in the ubuntu image,
|
||||
# allocate a tty, attach stdin and stdout
|
||||
docker run -i -t base /bin/bash
|
||||
docker run -i -t ubuntu /bin/bash
|
||||
|
||||
Bind Docker to another host/port or a unix socket
|
||||
-------------------------------------------------
|
||||
|
@ -52,8 +52,8 @@ For example:
|
|||
|
||||
# Run docker in daemon mode
|
||||
sudo <path to>/docker -H 0.0.0.0:5555 -d &
|
||||
# Download a base image
|
||||
docker -H :5555 pull base
|
||||
# Download an ubuntu image
|
||||
docker -H :5555 pull ubuntu
|
||||
|
||||
You can use multiple -H, for example, if you want to listen
|
||||
on both tcp and a unix socket
|
||||
|
@ -62,10 +62,10 @@ on both tcp and a unix socket
|
|||
|
||||
# Run docker in daemon mode
|
||||
sudo <path to>/docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock -d &
|
||||
# Download a base image
|
||||
docker pull base
|
||||
# Download an ubuntu image
|
||||
docker pull ubuntu
|
||||
# OR
|
||||
docker -H unix:///var/run/docker.sock pull base
|
||||
docker -H unix:///var/run/docker.sock pull ubuntu
|
||||
|
||||
Starting a long-running worker process
|
||||
--------------------------------------
|
||||
|
@ -73,7 +73,7 @@ Starting a long-running worker process
|
|||
.. code-block:: bash
|
||||
|
||||
# Start a very useful long-running process
|
||||
JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
|
||||
JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")
|
||||
|
||||
# Collect the output of the job so far
|
||||
docker logs $JOB
|
||||
|
@ -95,7 +95,7 @@ Expose a service on a TCP port
|
|||
.. code-block:: bash
|
||||
|
||||
# Expose port 4444 of this container, and tell netcat to listen on it
|
||||
JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
|
||||
JOB=$(docker run -d -p 4444 ubuntu /bin/nc -l -p 4444)
|
||||
|
||||
# Which public port is NATed to my container?
|
||||
PORT=$(docker port $JOB 4444)
|
||||
|
|
|
@ -53,13 +53,13 @@ defined type which can be used like so:
|
|||
|
||||
.. code-block:: ruby
|
||||
|
||||
docker::image { 'base': }
|
||||
docker::image { 'ubuntu': }
|
||||
|
||||
This is equivalent to running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker pull base
|
||||
docker pull ubuntu
|
||||
|
||||
Note that it will only if the image of that name does not already exist.
|
||||
This is downloading a large binary so on first run can take a while.
|
||||
|
@ -68,7 +68,7 @@ for exec. Note that you can also remove images you no longer need with:
|
|||
|
||||
.. code-block:: ruby
|
||||
|
||||
docker::image { 'base':
|
||||
docker::image { 'ubuntu':
|
||||
ensure => 'absent',
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ docker.
|
|||
.. code-block:: ruby
|
||||
|
||||
docker::run { 'helloworld':
|
||||
image => 'base',
|
||||
image => 'ubuntu',
|
||||
command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
|
||||
}
|
||||
|
||||
|
@ -89,14 +89,14 @@ This is equivalent to running the following command, but under upstart:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done"
|
||||
docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
|
||||
|
||||
Run also contains a number of optional parameters:
|
||||
|
||||
.. code-block:: ruby
|
||||
|
||||
docker::run { 'helloworld':
|
||||
image => 'base',
|
||||
image => 'ubuntu',
|
||||
command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
|
||||
ports => ['4444', '4555'],
|
||||
volumes => ['/var/lib/counchdb', '/var/log'],
|
||||
|
|
|
@ -146,7 +146,7 @@ cd docker\-master
|
|||
.sp
|
||||
.nf
|
||||
.ft C
|
||||
sudo ./docker run \-i \-t base /bin/bash
|
||||
sudo ./docker run \-i \-t ubuntu /bin/bash
|
||||
.ft P
|
||||
.fi
|
||||
.sp
|
||||
|
@ -496,22 +496,22 @@ This is the most basic example available for using docker
|
|||
.sp
|
||||
This example assumes you have Docker installed.
|
||||
.sp
|
||||
Download the base container
|
||||
Download the ubuntu container
|
||||
.sp
|
||||
.nf
|
||||
.ft C
|
||||
# Download a base image
|
||||
docker pull base
|
||||
# Download an ubuntu image
|
||||
docker pull ubuntu
|
||||
.ft P
|
||||
.fi
|
||||
.sp
|
||||
The \fIbase\fP image is a minimal \fIubuntu\fP based container, alternatively you can select \fIbusybox\fP, a bare
|
||||
minimal linux system. The images are retrieved from the docker repository.
|
||||
Alternatively you can select \fIbusybox\fP, a bare minimal linux system. The
|
||||
images are retrieved from the docker repository.
|
||||
.sp
|
||||
.nf
|
||||
.ft C
|
||||
#run a simple echo command, that will echo hello world back to the console over standard out.
|
||||
docker run base /bin/echo hello world
|
||||
docker run ubuntu /bin/echo hello world
|
||||
.ft P
|
||||
.fi
|
||||
.sp
|
||||
|
@ -520,7 +520,7 @@ docker run base /bin/echo hello world
|
|||
.IP \(bu 2
|
||||
\fB"docker run"\fP run a command in a new container
|
||||
.IP \(bu 2
|
||||
\fB"base"\fP is the image we want to run the command inside of.
|
||||
\fB"ubuntu"\fP is the image we want to run the command inside of.
|
||||
.IP \(bu 2
|
||||
\fB"/bin/echo"\fP is the command we want to run in the container
|
||||
.IP \(bu 2
|
||||
|
@ -536,15 +536,15 @@ Continue to the \fIhello_world_daemon\fP example.
|
|||
.sp
|
||||
The most boring daemon ever written.
|
||||
.sp
|
||||
This example assumes you have Docker installed and with the base image already imported \fBdocker pull base\fP.
|
||||
We will use the base image to run a simple hello world daemon that will just print hello world to standard
|
||||
This example assumes you have Docker installed and with the ubuntu image already imported \fBdocker pull ubuntu\fP.
|
||||
We will use the ubuntu image to run a simple hello world daemon that will just print hello world to standard
|
||||
out every second. It will continue to do this until we stop it.
|
||||
.sp
|
||||
\fBSteps:\fP
|
||||
.sp
|
||||
.nf
|
||||
.ft C
|
||||
$ CONTAINER_ID=$(docker run \-d base /bin/sh \-c "while true; do echo hello world; sleep 1; done")
|
||||
$ CONTAINER_ID=$(docker run \-d ubuntu /bin/sh \-c "while true; do echo hello world; sleep 1; done")
|
||||
.ft P
|
||||
.fi
|
||||
.sp
|
||||
|
@ -553,7 +553,7 @@ We are going to run a simple hello world daemon in a new container made from the
|
|||
.IP \(bu 2
|
||||
\fB"docker run \-d "\fP run a command in a new container. We pass "\-d" so it runs as a daemon.
|
||||
.IP \(bu 2
|
||||
\fB"base"\fP is the image we want to run the command inside of.
|
||||
\fB"ubuntu"\fP is the image we want to run the command inside of.
|
||||
.IP \(bu 2
|
||||
\fB"/bin/sh \-c"\fP is the command we want to run in the container
|
||||
.IP \(bu 2
|
||||
|
@ -766,12 +766,12 @@ Contents:
|
|||
.sp
|
||||
.nf
|
||||
.ft C
|
||||
# Download a base image
|
||||
docker import base
|
||||
# Download an ubuntu image
|
||||
docker import ubuntu
|
||||
|
||||
# Run an interactive shell in the base image,
|
||||
# Run an interactive shell in the ubuntu image,
|
||||
# allocate a tty, attach stdin and stdout
|
||||
docker run \-a \-i \-t base /bin/bash
|
||||
docker run \-a \-i \-t ubuntu /bin/bash
|
||||
.ft P
|
||||
.fi
|
||||
.SS Starting a long\-running worker process
|
||||
|
@ -782,7 +782,7 @@ docker run \-a \-i \-t base /bin/bash
|
|||
(docker \-d || echo "Docker daemon already running") &
|
||||
|
||||
# Start a very useful long\-running process
|
||||
JOB=$(docker run base /bin/sh \-c "while true; do echo Hello world!; sleep 1; done")
|
||||
JOB=$(docker run ubuntu /bin/sh \-c "while true; do echo Hello world!; sleep 1; done")
|
||||
|
||||
# Collect the output of the job so far
|
||||
docker logs $JOB
|
||||
|
@ -803,7 +803,7 @@ docker ps
|
|||
.nf
|
||||
.ft C
|
||||
# Expose port 4444 of this container, and tell netcat to listen on it
|
||||
JOB=$(docker run \-p 4444 base /bin/nc \-l \-p 4444)
|
||||
JOB=$(docker run \-p 4444 ubuntu /bin/nc \-l \-p 4444)
|
||||
|
||||
# Which public port is NATed to my container?
|
||||
PORT=$(docker port $JOB 4444)
|
||||
|
|
Loading…
Reference in a new issue