Skip to content

Latest commit

 

History

History
264 lines (201 loc) · 8.9 KB

appendix.md

File metadata and controls

264 lines (201 loc) · 8.9 KB

Appendix

{id: appendix}

Links

{id: links}

Companies using Docker in Israel

{id: docker-in-israel}

{aside} I know that most of the readers of these slides are from around the world, but I run most of my courses in Israel, so I have special interest in knowing which companies are using docker and what job titles do the people who use it have. At one point I might create similar pages for some other countries as well. {/aside}

Docker Toolbox

{id: docker-toolbox}

Legacy system

Docker Resources

{id: docker-resource}

Docker Whalesay

{id: docker-hub-whalesay}

Go to Docker Hub search for whalesay and note among the many hits there is one called 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:

$ 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

Volumes

{id: volumes}

docker run --mount source=myvol,target=/data --rm -it busybox

docker volume ls --format "{{.Driver}}  {{.Name}} {{.Mountpoint}}"

docker volume create myvol
    Creates /var/lib/docker/volumes/myvol

docker volume ls
docker volume inspect myvol  # Returns a JSON with information about the volume
docker volume rm myvol


docker-compose up
docker-compose rm

docker system df

{id: docker-system-df}

  • Show docker disk usage
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              6                   2                   3.464GB             1.579GB (45%)
Containers          4                   0                   71.02kB             71.02kB (100%)
Local Volumes       2                   2                   638.3MB             0B (0%)
Build Cache         0                   0                   0B                  0B

docker system prune

{id: docker-system-prune}

  • Remove all the unused data
  • See the flags
--all
--volumes

Docker history

{id: docker-history}

{aside} Each Docker image is built by layers upon layers.

The docker history command can show you these layers. {/aside}

docker history IMAGE

{aside} Here you can see that the Ubuntu image we have downloaded from the Docker Hub has 5 layers. {/aside}

$ docker history ubuntu:20.04

Docker history - multiple layers

{id: docker-history-multiple-layers}

{aside} If you run the same command on the mydocker image we have just created you can see that it has 2 more layers. Each RUN command created a layer.

Layers are created separately so having multiple layers makes our development process faster. However having many layers is not recommended so once in a while we usually merge the RUN instructions together and rebuild the image to have less layers. We'll talk about this later. {/aside}

docker history mydocker