A quick run-down of some of my most useful Docker commands: -
See what's running
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
See what images I have
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Run, and pull - if needed, a Docker container
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
See what images I have
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 5 weeks ago 1.84kB
See what images I have - without truncation
docker images --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e 5 weeks ago 1.84kB
See what's running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d0a99dfd9a4 hello-world "/hello" 16 seconds ago Exited (0) 15 seconds ago frosty_hypatia
See what's running - without truncation
docker ps -a --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d0a99dfd9a47cd9e336d56ab2fc83bd78ca80978d971dc276946041fdb40995 hello-world "/hello" 21 seconds ago Exited (0) 19 seconds ago frosty_hypatia
See what's under the hood - in terms of layers
docker history fce289e99eb9
IMAGE CREATED CREATED BY SIZE COMMENT
fce289e99eb9 5 weeks ago /bin/sh -c #(nop) CMD ["/hello"] 0B
And with a slightly (!) more advanced Docker image: -
docker run docker/whalesay cowsay boo
Unable to find image 'docker/whalesay:latest' locally
latest: Pulling from docker/whalesay
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
00bf65475aba: Pull complete
c57b6bcc83e3: Pull complete
8978f6879e2f: Pull complete
8eed3712d2cf: Pull complete
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest
_____
< boo >
-----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 5 weeks ago 1.84kB
docker/whalesay latest 6b362a9f73eb 3 years ago 247MB
docker history 6b362a9f73eb
IMAGE CREATED CREATED BY SIZE COMMENT
6b362a9f73eb 3 years ago /bin/sh -c #(nop) ENV PATH=/usr/local/bin:/u… 0B
docker inspect 6b362a9f73eb
[
{
"Id": "sha256:6b362a9f73eb8c33b48c95f4fcce1b6637fc25646728cf7fb0679b2da273c3f4",
"RepoTags": [
"docker/whalesay:latest"
],
"RepoDigests": [
"docker/whalesay@sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b"
],
"Parent": "",
"Comment": "",
"Created": "2015-05-25T22:04:23.303454458Z",
"Container": "5460b2353ce4e2b3e3e81b4a523a61c5adc238ae21d3ec3a5774674652e6317f",
"ContainerConfig": {
"Hostname": "9ec8c01a6a48",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Image": "5d5bd9951e26ca0301423625b19764bda914ae39c3f2bfd6f1824bf5354d10ee",
"Volumes": null,
"WorkingDir": "/cowsay",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "1.6.0",
"Author": "",
"Config": {
"Hostname": "9ec8c01a6a48",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "5d5bd9951e26ca0301423625b19764bda914ae39c3f2bfd6f1824bf5354d10ee",
"Volumes": null,
"WorkingDir": "/cowsay",
"Entrypoint": null,
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 247049019,
"VirtualSize": 247049019,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/793768003cdb0f4c4b76627e2fdaef447af26a570f293c9cd0efd4e93c980cea/diff:/var/lib/docker/overlay2/2b675a0417a328024a4d12480cbc8d59655c3fba039c870057cd37537e5bd05b/diff:/var/lib/docker/overlay2/2e2deecb066dd3582e77ffe750975cde90e45c77cce842be439e0ca5c4f0d0f6/diff:/var/lib/docker/overlay2/6f5991826733cb88f5e356deb6807ffb58160072cef0db687a5d9820bc7e3ba0/diff:/var/lib/docker/overlay2/84adea855c8ed41a82c005e381d5a3d31f9b5a84579fb0bc644d707c90f54dd3/diff:/var/lib/docker/overlay2/95b856d151d6253bc8311c4ab6908893274e7162517ac265e739a544da9f9190/diff:/var/lib/docker/overlay2/d3bfc7095c61ef75f4943fe3f9926c275b30a434e5af0dd276b2b635834b4467/diff:/var/lib/docker/overlay2/d0aa0bcc22e6a4bd5511d9e7933869cbcc4794087fa1520f77199597328a4f5c/diff:/var/lib/docker/overlay2/2ba2e03e60d5e8e0c84fcb59941417607ee78265f2545fe2cb4a489dd1dbd186/diff",
"MergedDir": "/var/lib/docker/overlay2/db32366024b39eb798f94baa6a84ca982ecbf7c575bed43aecc32ec137ebb180/merged",
"UpperDir": "/var/lib/docker/overlay2/db32366024b39eb798f94baa6a84ca982ecbf7c575bed43aecc32ec137ebb180/diff",
"WorkDir": "/var/lib/docker/overlay2/db32366024b39eb798f94baa6a84ca982ecbf7c575bed43aecc32ec137ebb180/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:1154ba695078d29ea6c4e1adb55c463959cd77509adf09710e2315827d66271a",
"sha256:528c8710fd95f61d40b8bb8a549fa8dfa737d9b9c7c7b2ae55f745c972dddacd",
"sha256:37ee47034d9b78f10f0c5ce3a25e6b6e58997fcadaf5f896c603a10c5f35fb31",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:b26122d57afa5c4a2dc8db3f986410805bc8792af3a4fa73cfde5eed0a8e5b6d",
"sha256:091abc5148e4d32cecb5522067509d7ffc1e8ac272ff75d2775138639a6c50ca",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:d511ed9e12e17ab4bfc3e80ed7ce86d4aac82769b42f42b753a338ed9b8a566d",
"sha256:d061ee1340ecc8d03ca25e6ca7f7502275f558764c1ab46bd1f37854c74c5b3f",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
No comments:
Post a Comment