Docker packages an application with its dependencies to create standard development environments. Wraps the application in a complete filesystem (called containers), so code will run EXACTLY the same regardless of environment.
cloud portability, using multiple cloud providers without locking into specific architecture
docker run hello-world
creates and runs a given image
In Docker, an image is a snapshot of the filesystem. It stores
Write a Dockerfile
, based on the whalesay image:
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
RUN
install software onto the imageCMD
instructs software to run when image is loadeddocker build -t <image-name>
takes the Dockerfile
in the current directory and builds an imagedocker run -p 26389:80 --name testing nginx
docker exec -i -t <container-id> /bin/bash
Containers serve similar purpose of resource isolation but with different architecture, aimed at portability and efficiency.
Virtual Machines include the application, dependencies and entire guest OS, which could be tens of GBs.
Containers include application and dependencies, but share kernal with other containers. They are not tied to any OS infrastructure.
Docker is more specific, less flexible than Vagrant. Vagrant is catered to managing independent machines, while Docker is for building and running application environments.