diff --git a/docker.html.markdown b/docker.html.markdown index 1df49cc3..e18db5c9 100644 --- a/docker.html.markdown +++ b/docker.html.markdown @@ -5,144 +5,277 @@ filename: docker.bat contributors: - ["Ruslan López", "http://javapro.org/"] - ["Michael Chen", "https://github.com/ML-Chen"] + - ["Akshita Dixit", "https://github.com/akshitadixit"] + - ["Marcel Ribeiro-Dantas", "https://github.com/mribeirodantas"] --- -```bat -:: download, install and run hello-world image -docker run hello-world +Docker is a tool that helps you build, test, ship and run applications +seamlessly across various machines. It replicates the environment our software +needs on any machine. You can get Docker for your machine from +https://docs.docker.com/get-docker/ -:: if this is the first time you should be able to see the message -:: Unable to find image 'hello-world:latest' locally -:: latest: Pulling from library/hello-world -:: 1b930d010525: Pull complete -:: Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064 -:: 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/ +It has grown in popularity over the last decade due to being lightweight and +fast as compared to virtual-machines that are bulky and slow. Unlike VMs, docker +does not need a full blown OS of its own to be loaded to start and does not +compete for resources other than what the application it is running will use. +VMs on the other hand are pretty resource intensive on our processors, disks and +memory hence running multiple VMs for various applications becomes a challenge +in a limited capacity architecture. -:: now let's see currently running images -docker ps -:: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS -:: NAMES +
+┌────────────────────────┐ ┌───────────────────────┐ +│ ┌───────────┐ │ │ ┌───────────┐ │ +│ │ App │ │ │ │ App │ │ +│ └───────────┘ │ │ └───────────┘ │ +│ ┌────────┐ ┌────────┐ │ │ ┌────────┐ ┌───────┐ │ +│ │ Libs │ │ Deps │ │ │ │ Libs │ │ Deps │ │ +│ └────────┘ └────────┘ │ │ └────────┘ └───────┘ │ +│ ┌───────────────────┐ │ │ ┌──────────────────┐ │ +│ │ Guest OS │ │ │ │ Guest OS │ │ +│ └───────────────────┘ │ │ └──────────────────┘ │ +│ VM1 │ │ VM2 │ +└────────────────────────┘ └───────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ Hypervisor │ +└──────────────────────────────────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ Host OS │ +└──────────────────────────────────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ Hardware Infrastructure │ +└──────────────────────────────────────────────────┘ + (VM based architecture) -:: let's see the images we have ran previously -docker ps -a +┌────────────────────────┐ ┌───────────────────────┐ +│ ┌───────────┐ │ │ ┌───────────┐ │ +│ │ App │ │ │ │ App │ │ +│ └───────────┘ │ │ └───────────┘ │ +│ ┌────────┐ ┌────────┐ │ │ ┌────────┐ ┌───────┐ │ +│ │ Libs │ │ Deps │ │ │ │ Libs │ │ Deps │ │ +│ └────────┘ └────────┘ │ │ └────────┘ └───────┘ │ +│ Container1 │ │ Container2 │ +└────────────────────────┘ └───────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ Docker │ +└──────────────────────────────────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ OS │ +└──────────────────────────────────────────────────┘ +┌──────────────────────────────────────────────────┐ +│ Hardware Infrastructure │ +└──────────────────────────────────────────────────┘ + (Docker based architecture) -:: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS -:: NAMES -:: 4a76281f9c53 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago -:: happy_poincare -:: the name part is generated automatically so it probably will be different for you +-:: let's remove our previously generated image -docker rm happy_poincare +Couple of terms we will encounter frequently are Docker Images and Docker +Containers. Images are packages or templates of containers all stored in a +container registry such as [Docker Hub](https://hub.docker.com/). Containers +are standalone, executable instances of these images which include code, +runtime, system tools, system libraries and settings - everything required to +get the software up and running. Coming to Docker, it follows a client-server +architecture wherein the CLI client communicates with the server component, +which here is, the Docker Engine using RESTful API to issue commands. -:: let's test if it was really deleted -docker ps -a -:: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS -:: NAMES +## The Docker CLI +```bash +# after installing Docker from https://docs.docker.com/get-docker/ +# To list available commands, either run `docker` with no parameters or execute +# `docker help` +$ docker -:: specify a custom name for the container -docker run --name test_container hello-world -:: 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/ +>>> docker [OPTIONS] COMMAND [ARG...] + docker [ --help | -v | --version ] -docker ps -a -:: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS -:: NAMES -:: d345fe1a4f41 hello-world "/hello" About a minute ago Exited (0) About a minute ago -:: test_container -:: as you can see the name is now what we have specified + A self-sufficient runtime for containers. -:: retrieve logs from a named container -docker logs test_container -:: 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/ + Options: + --config string Location of client config files (default "/root/.docker") + -c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use") + -D, --debug Enable debug mode + --help Print usage + -H, --host value Daemon socket(s) to connect to (default []) + -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") + --tls Use TLS; implied by --tlsverify + --tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem") + --tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem") + --tlskey string Path to TLS key file (default "/root/.docker/key.pem") + --tlsverify Use TLS and verify the remote + -v, --version Print version information and quit -docker rm test_container + Commands: + attach Attach to a running container + # […] -docker run ubuntu -:: Unable to find image 'ubuntu:latest' locally -:: latest: Pulling from library/ubuntu -:: 2746a4a261c9: Pull complete -:: 4c1d20cdee96: Pull complete 0d3160e1d0de: Pull complete c8e37668deea: Pull complete Digest: sha256:250cc6f3f3ffc5cdaa9d8f4946ac79821aafb4d3afc93928f0de9336eba21aa4 -:: Status: Downloaded newer image for ubuntu:latest +$ docker run hello-world +# `docker run