Skip to content

Instantly share code, notes, and snippets.

@mingderwang
Created July 15, 2014 08:21
Show Gist options
  • Save mingderwang/6b8129e112f4a5d1e813 to your computer and use it in GitHub Desktop.
Save mingderwang/6b8129e112f4a5d1e813 to your computer and use it in GitHub Desktop.
have fun with docker try! http://www.docker.com/tryit
you@tutorial:~$ docker run learn/tutorial echo hello world
hello world
you@tutorial:~$ docker run learn/tutorial apt-get install -y ping
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 1s (50.3 kB/s)
Selecting previously unselected package iputils-ping.
(Reading database ... 7545 files and directories currently installed.)
Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ...
Setting up iputils-ping (3:20101006-1ubuntu1) ...
you@tutorial:~$ docker ps -l
ID IMAGE COMMAND CREATED STATUS PORTS
6982a9948422 ubuntu:12.04 apt-get install ping 1 minute ago Exit 0
you@tutorial:~$ docker commit
Usage: Docker commit [OPTIONS] CONTAINER [REPOSITORY [TAG]]
Create a new image from a container's changes
-author="": Author (eg. "John Hannibal Smith <[email protected]>"
-m="": Commit message
-run="": Config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
tutorial:~$ docker commit learn/ping 6982 init
effb66b31edb
you@tutorial:~$ docker run learn/ping ping www.google.com
PING www.google.com (74.125.239.129) 56(84) bytes of data.
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=1 ttl=55 time=2.23 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=2 ttl=55 time=2.30 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=3 ttl=55 time=2.27 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=4 ttl=55 time=2.30 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=5 ttl=55 time=2.25 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=6 ttl=55 time=2.29 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=7 ttl=55 time=2.23 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=8 ttl=55 time=2.30 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=9 ttl=55 time=2.35 ms
-> This would normally just keep going. However, this emulator does not support Ctrl-C, so we quit here.
you@tutorial:~$ docker ps
ID IMAGE COMMAND CREATED STATUS PORTS
efefdc74a1d5 learn/ping:latest ping www.google.com 37 seconds ago Up 36 seconds
you@tutorial:~$ docker inspect efef
[2013/07/30 01:52:26 GET /v1.3/containers/efef/json
{
"ID": "efefdc74a1d5900d7d7a74740e5261c09f5f42b6dae58ded6a1fde1cde7f4ac5",
"Created": "2013-07-30T00:54:12.417119736Z",
"Path": "ping",
"Args": [
"www.google.com"
],
"Config": {
"Hostname": "efefdc74a1d5",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"PortSpecs": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"ping",
"www.google.com"
],
"Dns": null,
"Image": "learn/ping",
"Volumes": null,
"VolumesFrom": "",
"Entrypoint": null
},
"State": {
"Running": true,
"Pid": 22249,
"ExitCode": 0,
"StartedAt": "2013-07-30T00:54:12.424817715Z",
"Ghost": false
},
"Image": "a1dbb48ce764c6651f5af98b46ed052a5f751233d731b645a6c57f91a4cb7158",
"NetworkSettings": {
"IPAddress": "172.16.42.6",
"IPPrefixLen": 24,
"Gateway": "172.16.42.1",
"Bridge": "docker0",
"PortMapping": {
"Tcp": {},
"Udp": {}
}
},
"SysInitPath": "/usr/bin/docker",
"ResolvConfPath": "/etc/resolv.conf",
"Volumes": {},
"VolumesRW": {}
>> docker push learn/ping
...
_ _ _ _
__ _____| | | __| | ___ _ __ ___ | |
\ \ /\ / / _ \ | | / _` |/ _ \| '_ \ / _ \ | |
\ V V / __/ | | | (_| | (_) | | | | __/ |_|
\_/\_/ \___|_|_| \__,_|\___/|_| |_|\___| (_)
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
| |
__ | __ __ | _ __ _
/ \| / \ / |/ / _\ |
\__/| \__/ \__ |\_ \__ |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment