Last active
March 17, 2018 00:38
-
-
Save vrgurus/4da93d6bd5093042cca4a06da42c88f7 to your computer and use it in GitHub Desktop.
docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker version | |
$ docker run debian echo "hello world" | |
Unable to find image 'debian:latest' locally | |
latest: Pulling from library/debian | |
3e731ddb7fc9: Pull complete | |
Digest: sha256:4fcd8c0b6f5e3bd44a3e63be259fd0c038476d432953d449ef34aedf16def331 | |
Status: Downloaded newer image for debian:latest | |
hello world | |
$ docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
debian latest 1b3ec9d977fb 3 weeks ago 100MB | |
$ docker ps -a | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
1255ab138c08 debian "echo 'hello world'" 2 minutes ago Exited (0) 2 minutes ago hardcore_mayer | |
$ docker run -i -t debian /bin/bash | |
root@d8a067db43a9:/# echo "hello from container" | |
hello from container | |
root@d8a067db43a9:/# exit | |
exit | |
$ docker diff quirky_kalam # diff from original image | |
A /bash | |
A /bash/bash | |
A /bash/cat | |
A /bash/chgrp | |
$ docker ps -a # Show all containers including archived | |
$ docker inspect 3f91bd108f39 # inspect conatiner | |
$ docker inspect 3f91bd108f39 | grep IPAddress | |
"SecondaryIPAddresses": null, | |
"IPAddress": "172.17.0.2", | |
"IPAddress": "172.17.0.2", | |
$ docker inspect --format {{.NetworkSettings.IPAddress}} 3f91bd108f39 | |
172.17.0.2 | |
$ docker logs 3f91bd108f39 # inspect command history | |
$ docker ps -aq -f status=exited # show stopped container | |
87233f96dc49 | |
bd5452f58f76 | |
d8a067db43a9 | |
1255ab138c08 | |
$ docker rm -v $(docker ps -aq -f status=exited) # remove all stopped containers, including non-ref volumes | |
$ docker run -h CONTAINER -it --rm debian /bin/bash # remove container when exited | |
$docker run -it --name cowsay --hostname cowsay debian bash | |
root@cowsay:/# apt-get update | |
Get:1 http://security.debian.org stretch/updates InRelease [63.0 kB] | |
.... | |
Reading package lists... Done | |
root@cowsay:/# apt-get install -y cowsay fortune | |
Reading package lists... Done | |
... | |
Processing triggers for libc-bin (2.24-11+deb9u1) ... | |
root@cowsay:/# /usr/games/fortune | /usr/games/cowsay | |
____________________________________ | |
/ The smallest worm will turn being \ | |
| trodden on. | | |
| | | |
\ -- William Shakespeare, "Henry VI" / | |
------------------------------------ | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
root@cowsay:/# | |
$ docker commit cowsay test/cowsayimage # Commit container after running above command | |
sha256:5fe981e55fa7a0d5e8d2980008f9247a175a42cb99910b72bc8085796ab1076d | |
$ docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
test/cowsayimage latest 5fe981e55fa7 48 seconds ago 158MB | |
debian latest 1b3ec9d977fb 3 weeks ago 100MB | |
$ docker run test/cowsayimage /usr/games/cowsay "Moo" | |
_____ | |
< Moo > | |
----- | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment