Docker notes, small projects, and solutions from several sources.
- A way to package application with all the necessary dependencies and configurations
- Portable artifact, easily shared and moved around
- Makes development and deployment more efficient.
- Layers of images
- Mostly Linux Base Image, bc small in size
- Application image on top
Containers live in container repositories:
- Private repositories
- Public repository for Docker (e.g: DockerHub)
- Installation process different on each OS environment
- Many steps where something could go wrong
- Configuration on server needed: Dependency version conflicts
- Textual guide of deployment: Misunderstandings
- Own isolated environment (based on lightweight linux)
- Packaged with all needed configuration
- One command to install the app
- Run same app with 2 different versions
- Developers and Operations work together to package the application in a container
- No environmental configuration needed on server (except Docker Runtime)
- Image:
- The actual package
- Artifact, that can be moved around
- Container:
- Actually start the application
- Container environment is created
The difference lies on what parts of the operating system they virtualize:
- Docker virtualizes the Applications layer
- Virtual Machines virtualizes the OS Kernel and the Applications layer
This means:
- Size: The size of Docker images are much smaller (couple of MB)
- Speed: Docker containers start and run much fast
- Compatibility: VM of any OS can run on any OS host -- Docker can't do this, a workaround is installing a technology called Docker Toolbox which abstracts away the Kernel
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. - Wikipedia
From the above definition, basically, Docker consists of three things:
- A set of Platform as a Service (PaaS)
- Docker uses OS-level virtualization
- For delivery of software in packages called containers
Command | Explanation | Shorthand |
---|---|---|
docker image ls |
Lists all images | docker images |
docker image rm [image] |
Removes an image | docker rmi |
docker image pull [image] |
Pulls image from a docker registry | docker pull |
docker container ls |
Lists running containers | docker ps |
docker container ls -a |
Lists all containers | docker ps -a |
docker container run [image] |
Runs a container from an image | docker run [image] |
docker container rm [container] |
Removes a container | docker rm [container] |
docker container stop [container] |
Stops a container | docker stop [container] |
docker container exec [container] |
Executes a command inside the container | docker exec [container] |