A few months back I taught a workshop for the FullStack Community in Cluj regarding this very subject,
Getting started with Docker. Given the popularity of the subject and the positive review of the workshop, I decided to start writing this series in which I plan to cover the basics of Docker, Docker Compose, Open Stack and Jenkins, culminating in
Continuous Delivery with Docker, Jenkins on Open Stack.
So, why Docker?
Docker innovated over the virtual machine architecture popular at the time by the simple fact that a Docker container runs natively on Linux and shares the kernel of the host machine with other containers. It runs as a discrete process, taking no more memory than any other executable, making it lightweight. By contrast, a virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.
I'm going to skip over the installation process and just link to their documentation since is very well written.
Mac Os X
- Install Docker For Mac.
- Install Docker For Windows.
- Install Docker CE.
Docker introduced three basic concepts to describe how the end user should interact with the stack.
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
An image is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files.
A container is a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process).
docker build -t <tag> .build a docker image with a set
docker imageslist all docker images
docker rmi <image-id>remove an image
docker run -d --name <name> -p <port> -e <env> -v <host>:<path> <image>start a container with the name
<name>running on port
<port>with env variables
<host>folder mapped to
<path>in container based on
docker pslist all running containers
docker ps -alist all containers running or not
docker stop <container>stop a running container
docker restart <container>restart a running container
In conclusion, if you got this far you should at least have a basic grasp of what Docker is and what it does.