|
...
|
...
|
@@ -140,111 +140,25 @@ Note that Docker doesn't care *how* dependencies are built - as long
|
|
140
|
140
|
as they can be built by running a Unix command in a container.
|
|
141
|
141
|
|
|
142
|
142
|
|
|
143
|
|
-Install instructions
|
|
144
|
|
-==================
|
|
|
143
|
+Getting started
|
|
|
144
|
+===============
|
|
145
|
145
|
|
|
146
|
146
|
Docker can be installed on your local machine as well as servers - both bare metal and virtualized.
|
|
147
|
147
|
It is available as a binary on most modern Linux systems, or as a VM on Windows, Mac and other systems.
|
|
148
|
148
|
|
|
149
|
|
-For the most up-to-date install instructions, see the [install page on the documentation](http://docs.docker.io/en/latest/installation/).
|
|
|
149
|
+We also offer an interactive tutorial for quickly learning the basics of using Docker.
|
|
150
|
150
|
|
|
151
|
151
|
|
|
152
|
|
-Usage examples
|
|
153
|
|
-==============
|
|
154
|
|
-
|
|
155
|
|
-First run the ``docker`` daemon
|
|
156
|
|
-
|
|
157
|
|
-All the examples assume your machine is running the ``docker``
|
|
158
|
|
-daemon. To run the ``docker`` daemon in the background, simply type:
|
|
159
|
|
-
|
|
160
|
|
-```bash
|
|
161
|
|
-# On a production system you want this running in an init script
|
|
162
|
|
-sudo docker -d &
|
|
163
|
|
-```
|
|
164
|
|
-
|
|
165
|
|
-Now you can run ``docker`` in client mode: all commands will be
|
|
166
|
|
-forwarded to the ``docker`` daemon, so the client can run from any
|
|
167
|
|
-account.
|
|
168
|
|
-
|
|
169
|
|
-```bash
|
|
170
|
|
-# Now you can run docker commands from any account.
|
|
171
|
|
-docker help
|
|
172
|
|
-```
|
|
|
152
|
+For up-to-date install instructions and online tutorials, see the [Getting Started page](http://www.docker.io/gettingstarted/).
|
|
173
|
153
|
|
|
174
|
154
|
|
|
175
|
|
-Throwaway shell in a base Ubuntu image
|
|
176
|
|
-
|
|
177
|
|
-```bash
|
|
178
|
|
-docker pull ubuntu:12.10
|
|
179
|
|
-
|
|
180
|
|
-# Run an interactive shell, allocate a tty, attach stdin and stdout
|
|
181
|
|
-# To detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q
|
|
182
|
|
-docker run -i -t ubuntu:12.10 /bin/bash
|
|
183
|
|
-```
|
|
184
|
|
-
|
|
185
|
|
-Starting a long-running worker process
|
|
186
|
|
-
|
|
187
|
|
-```bash
|
|
188
|
|
-# Start a very useful long-running process
|
|
189
|
|
-JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")
|
|
190
|
|
-
|
|
191
|
|
-# Collect the output of the job so far
|
|
192
|
|
-docker logs $JOB
|
|
193
|
|
-
|
|
194
|
|
-# Kill the job
|
|
195
|
|
-docker kill $JOB
|
|
196
|
|
-```
|
|
197
|
|
-
|
|
198
|
|
-Running an irc bouncer
|
|
199
|
|
-
|
|
200
|
|
-```bash
|
|
201
|
|
-BOUNCER_ID=$(docker run -d -p 6667 -u irc shykes/znc zncrun $USER $PASSWORD)
|
|
202
|
|
-echo "Configure your irc client to connect to port $(docker port $BOUNCER_ID 6667) of this machine"
|
|
203
|
|
-```
|
|
204
|
|
-
|
|
205
|
|
-Running Redis
|
|
206
|
|
-
|
|
207
|
|
-```bash
|
|
208
|
|
-REDIS_ID=$(docker run -d -p 6379 shykes/redis redis-server)
|
|
209
|
|
-echo "Configure your redis client to connect to port $(docker port $REDIS_ID 6379) of this machine"
|
|
210
|
|
-```
|
|
211
|
|
-
|
|
212
|
|
-Share your own image!
|
|
213
|
|
-
|
|
214
|
|
-```bash
|
|
215
|
|
-CONTAINER=$(docker run -d ubuntu:12.10 apt-get install -y curl)
|
|
216
|
|
-docker commit -m "Installed curl" $CONTAINER $USER/betterbase
|
|
217
|
|
-docker push $USER/betterbase
|
|
218
|
|
-```
|
|
219
|
|
-
|
|
220
|
|
-A list of publicly available images is [available
|
|
221
|
|
-here](https://github.com/dotcloud/docker/wiki/Public-docker-images).
|
|
222
|
|
-
|
|
223
|
|
-Expose a service on a TCP port
|
|
224
|
|
-
|
|
225
|
|
-```bash
|
|
226
|
|
-# Expose port 4444 of this container, and tell netcat to listen on it
|
|
227
|
|
-JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
|
|
228
|
|
-
|
|
229
|
|
-# Which public port is NATed to my container?
|
|
230
|
|
-PORT=$(docker port $JOB 4444)
|
|
|
155
|
+Usage examples
|
|
|
156
|
+==============
|
|
231
|
157
|
|
|
232
|
|
-# Connect to the public port via the host's public address
|
|
233
|
|
-# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
|
|
234
|
|
-# Replace *eth0* according to your local interface name.
|
|
235
|
|
-IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')
|
|
236
|
|
-echo hello world | nc $IP $PORT
|
|
|
158
|
+Docker can be used to run short-lived commands, long-running daemons (app servers, databases etc.),
|
|
|
159
|
+interactive shell sessions, etc.
|
|
237
|
160
|
|
|
238
|
|
-# Verify that the network connection worked
|
|
239
|
|
-echo "Daemon received: $(docker logs $JOB)"
|
|
240
|
|
-```
|
|
|
161
|
+You can find a [list of real-world examples](http://docs.docker.io/en/latest/examples/) in the documentation.
|
|
241
|
162
|
|
|
242
|
163
|
Under the hood
|
|
243
|
164
|
--------------
|