From 241c8319329b98adcae79f78d6d6ec864ec653ad Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Tue, 2 Jun 2020 17:15:41 +0300 Subject: [PATCH] move --- docker/appendix.md | 95 +++++++++++++++++++++++++++++++ docker/commands.md | 126 ----------------------------------------- docker/create-image.md | 16 ++++++ docker/docker.json | 1 + docker/networking.md | 20 +++++++ 5 files changed, 132 insertions(+), 126 deletions(-) create mode 100644 docker/networking.md diff --git a/docker/appendix.md b/docker/appendix.md index f2c5457c3..49ac806bb 100644 --- a/docker/appendix.md +++ b/docker/appendix.md @@ -68,4 +68,99 @@ At one point I might create similar pages for some other countries as well. Legacy system +## Docker Resources +{id: docker-resource} + + +* [Docker Documentation](https://docs.docker.com/) +* [Docker on Code-Maven](https://code-maven.com/docker) +* [Docker Tutorial for Beginners](https://www.youtube.com/watch?v=VlSW-tztsvM) +* [Docker Tutorial For Beginners](https://www.youtube.com/watch?v=sRIxHHZFwBA) +* [Docker Curriculum](https://docker-curriculum.com/) + +## Docker Whalesay +{id: docker-hub-whalesay} + +Go to [Docker Hub](https://hub.docker.com/) search for *whalesay* and note among the many hits there is one called +[docker/whalesay](https://hub.docker.com/r/docker/whalesay/). We'll use that one. + +``` +$ docker run docker/whalesay cowsay hello world + +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 + _____________ +< hello world > + ------------- + \ + \ + \ + ## . + ## ## ## == + ## ## ## ## === + /""""""""""""""""___/ === + ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ + \______ o __/ + \ \ __/ + \____\______/ +``` + +## Docker ps after whalesay +{id: docker-ps-whalesay} + +``` +$ docker ps -as + +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +59c99df0177a docker/whalesay "cowsay hello world" 36 minutes ago Exited (0) 23 minutes ago loving_wescoff 0 B (virtual 247 MB) +f6239f10a6ad hello-world "/hello" About an hour ago Exited (0) 58 minutes ago lucid_snyder 0 B (virtual 1.84 kB) +``` + +``` +$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +hello-world latest 48b5124b2768 6 weeks ago 1.84 kB +docker/whalesay latest 6b362a9f73eb 21 months ago 247 MB +``` + +## Docker whale (create Docker image) +{id: docker-whale} + +Create *Dockerfile* with the following content: + +![](examples/first/Dockerfile) + +``` +$ docker build -t docker-whale . +... +``` + +``` +$ docker images +REPOSITORY TAG IMAGE ID CREATED SIZE +docker-whale latest d5cf6bf32c0f 24 seconds ago 277 MB +hello-world latest 48b5124b2768 6 weeks ago 1.84 kB +docker/whalesay latest 6b362a9f73eb 21 months ago 247 MB +``` + +The command `docker ps -a` shows nothing new. + +## Run Docker whale +{id: run-docker-whale} + +``` +$ docker run docker-whale +``` + diff --git a/docker/commands.md b/docker/commands.md index 8c33f9ef5..0a7c28d41 100644 --- a/docker/commands.md +++ b/docker/commands.md @@ -80,117 +80,6 @@ docker exec -it 0ca23b8a9802 bash docker kill ID if it does not want to stop ``` -## Docker Resources -{id: docker-resource} - - -* [Docker Documentation](https://docs.docker.com/) -* [Docker on Code-Maven](https://code-maven.com/docker) -* [Docker Tutorial for Beginners](https://www.youtube.com/watch?v=VlSW-tztsvM) -* [Docker Tutorial For Beginners](https://www.youtube.com/watch?v=sRIxHHZFwBA) -* [Docker Curriculum](https://docker-curriculum.com/) - - -## Docker create image by save -{id: docker-create-image-by-save} - -``` -docker run -it debian -apt-get update -apt-get install htop -exit - -docker commit 3db0a970e422 USERNAME/debian:1.00 -docker run --rm -it USERNAME/debian:1.00 -``` - -Check the history! - -## Docker Whalesay -{id: docker-hub-whalesay} - -Go to [Docker Hub](https://hub.docker.com/) search for *whalesay* and note among the many hits there is one called -[docker/whalesay](https://hub.docker.com/r/docker/whalesay/). We'll use that one. - -``` -$ docker run docker/whalesay cowsay hello world - -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 - _____________ -< hello world > - ------------- - \ - \ - \ - ## . - ## ## ## == - ## ## ## ## === - /""""""""""""""""___/ === - ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ - \______ o __/ - \ \ __/ - \____\______/ -``` - -## Docker ps after whalesay -{id: docker-ps-whalesay} - -``` -$ docker ps -as - -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -59c99df0177a docker/whalesay "cowsay hello world" 36 minutes ago Exited (0) 23 minutes ago loving_wescoff 0 B (virtual 247 MB) -f6239f10a6ad hello-world "/hello" About an hour ago Exited (0) 58 minutes ago lucid_snyder 0 B (virtual 1.84 kB) -``` - -``` -$ docker images - -REPOSITORY TAG IMAGE ID CREATED SIZE -hello-world latest 48b5124b2768 6 weeks ago 1.84 kB -docker/whalesay latest 6b362a9f73eb 21 months ago 247 MB -``` - -## Docker whale (create Docker image) -{id: docker-whale} - -Create *Dockerfile* with the following content: - -![](examples/first/Dockerfile) - -``` -$ docker build -t docker-whale . -... -``` - -``` -$ docker images -REPOSITORY TAG IMAGE ID CREATED SIZE -docker-whale latest d5cf6bf32c0f 24 seconds ago 277 MB -hello-world latest 48b5124b2768 6 weeks ago 1.84 kB -docker/whalesay latest 6b362a9f73eb 21 months ago 247 MB -``` - -The command `docker ps -a` shows nothing new. - -## Run Docker whale -{id: run-docker-whale} - -``` -$ docker run docker-whale -``` - ## Dockerfile {id: docker-dockerfile} @@ -302,21 +191,6 @@ docker logs CONTAINER_ID * [logs](https://docs.docker.com/engine/reference/commandline/logs/) -## Docker networking -{id: docker-networking} - -``` -docker network list -NETWORK ID NAME DRIVER SCOPE -234aa213ed9a bridge bridge local -63a0fd629d21 host host local -37a165457dad none null local -``` - -``` -docker network create abc creates a bridge called abc -``` - ## Ignore files and directories {id: ignore-files-and-directories} {i: .dockerignore} diff --git a/docker/create-image.md b/docker/create-image.md index 1ec7e5450..8c2dfc5a5 100644 --- a/docker/create-image.md +++ b/docker/create-image.md @@ -77,6 +77,22 @@ There are two ways to create a Docker image on your computer: * Run a container, install stuff, stop it, commit it. * Create Dockerfile, run docker build. +## Docker create image by save +{id: docker-create-image-by-save} + +``` +docker run -it debian +apt-get update +apt-get install htop +exit + +docker commit 3db0a970e422 USERNAME/debian:1.00 +docker run --rm -it USERNAME/debian:1.00 +``` + +Check the history! + + ## Create image from container {id: create-image-from-container} {i: commit} diff --git a/docker/docker.json b/docker/docker.json index c937c662b..d22c88c01 100644 --- a/docker/docker.json +++ b/docker/docker.json @@ -12,6 +12,7 @@ "python.md", "perl.md", "compose.md", + "networking.md", "appendix.md" ] } diff --git a/docker/networking.md b/docker/networking.md new file mode 100644 index 000000000..70e81f725 --- /dev/null +++ b/docker/networking.md @@ -0,0 +1,20 @@ +# Docker networking +{id: docker-networking} + + +## Docker network list +{id: docker-network-list} + +``` +docker network list +NETWORK ID NAME DRIVER SCOPE +234aa213ed9a bridge bridge local +63a0fd629d21 host host local +37a165457dad none null local +``` + +``` +docker network create abc creates a bridge called abc +``` + +