Virtual Machines provide the functionality to execute entire operating systems. They run on top of a Hypervisor which provides access to the computer's hardware.
Docker creates a lightweight executable package of a piece of software and provides everything you need to run it.
Docker was not made by a single entity. It is forged through the combination of 3 components.
Term | Glossary |
---|---|
Dockerfile | A text file containing all the commands needed to build each layer of a image sequentially |
Context | The files in the same folder as your docker file |
Build | The process of building an image from a Dockerfile |
Image | An ordered collection of root filesystem changes and the execution parameters for your application |
Container | A runtime instance of a Docker Image |
Compose | A tool for defining and running multi container applications with docker |
Repository | A set of docker images |
Registry | A place to publish and share docker images |
Swarm | A cluster of one or more containers running in parallel |
The Dockerfile defines the docker build steps.
FROM - The base image
RUN - Run any bash commands
COPY - Copy files from System to Container
EXPOSE - Open any ports
CMD - This command is ran on container start
WORKDIR - Sets DIR for commands
# Base Image Node.js version 9.5.0
FROM node:9.5.0
# Copy source code
COPY . /app
# Set working directory
WORKDIR /app
# Install application dependencies
RUN npm Install
# Configure networking
EXPOSE 80
# Run on docker application start
CMD ['npm', 'start']
docker build
Creates Docker Image from a Dockerfile
docker images
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker ps
Docker Compose is a tool to define and run multi container applications
It is configured with yaml
To compose your application
docker-compose up -d