Professional Documents
Culture Documents
!
$ alias dl='docker ps -l -q'!
$ docker run ubuntu echo hello world!
hello world!
$ dl!
1904cf045887!
$ docker commit `dl` helloworld!
fd08a884dc79!
3. Su-su-sudo
TOMATO
TOMAHTO
10
#
$
!
#
$
!
#
$
!
#
$
!
11
12
!
!
$ docker rm $(docker ps -a -q)!
13
14
!
$ docker inspect `dl` | \!
grep IPAddress | cut -d '"' -f 4!
172.17.0.52!
!
$ docker inspect `dl` | \!
jq -r '.[0].NetworkSettings.IPAddress'!
172.17.0.52!
!
15
16
!
$ docker run ubuntu env!
HOME=/!
PATH=/usr/local/sbin:/usr/local/bin:/
usr/sbin:/usr/bin:/sbin:/bin!
container=lxc!
HOSTNAME=5e1560b7f757!
17
18
!
FROM thelanddownunder!
MAINTAINER crocdundee!
!
# docker build will execute these:!
RUN apt-get update!
RUN apt-get install softwares!
!
# docker run runs this cmd by default:!
CMD
["softwares"]!
A
Dockerle.
15
Docker
Tips
in
5
Minutes
19
20
!
$ cat Dockerfile!
FROM ubuntu!
CMD ["echo"]!
!
$ docker run \
imagename \
echo hello!
hello!
!
Overrideable.
15
Docker
Tips
in
5
Minutes
!
$ cat Dockerfile!
FROM ubuntu!
ENTRYPOINT ["echo"]!
!
$ docker run \
imagename \
echo hello!
echo hello!
!
Not overrideable.
21
22
!
$ ip -4 -o addr show eth0!
2: eth0
inet 162.243.139.222/24!
!
$ docker run ubuntu \!
ip -4 -o addr show eth0!
149: eth0
inet 172.17.0.43/16!
23
24
!
# Connect to the UNIX socket and make!
# like an HTTP client.!
$ nc -U //var/run/docker.sock!
GET /images/json HTTP/1.1!
!
HTTP/1.1 200 OK!
Content-Type: application/json!
Date: Tue, 05 Nov 2013 23:18:09 GMT!
Transfer-Encoding: chunked!
!
16aa!
[{"Repository":"postgres","Tag":.........!
25
26
!
# Generate an image dependency diagram!
$ docker images -viz | \!
dot -Tpng -o docker.png!
!
# To see it, run this on the host:!
$ python -m SimpleHTTPServer!
!
# then browse to:!
# http://machinename:8000/docker.png!
27
28
29
30
!
$ sudo su!
# cd /var/lib/docker!
# ls -F!
containers/ graph/ repositories
volumes/!
Explore!
graph
means
images.
Filesystem
layers
are
in
graph/imageid/layer.
15
Docker
Tips
in
5
Minutes
31
32
33
commands.go
The
CLI.
api.go
The
REST
API
router.
server.go
ImplementaGon
of
much
of
the
the
REST
API.
buildle.go
The
Dockerle
parser.
15
Docker
Tips
in
5
Minutes
34
35
$ cat Dockerfile!
FROM ubuntu:12.04!
MAINTAINER Brian Morearty!
...!
RUN pg_ctl start ...!
!
$ docker run -i -t postgresimage bash!
root@08d363f57161:/# ps aux!
# Doesnt
show postgres daemon!
36
37
38
#
$
!
#
#
$
39
Extracted
from
my
intro-level
Hands
on
with
Docker
class.
(In
partnership
with
Docker,
Inc.)
Beta
class
this
Monday,
6-9pm.
handsonwith.com
15
Docker
Tips
in
5
Minutes