Introduction to Docker

What is Docker?

An open platform for distributed applications 

It's based on Linux containers

A configurable Lightweight and Fast Virtual Machine Like environment

Linux Containers

Allows you to pack an application along with its stack
Abstract application from the guest OS

Prevents dependency hell

Big companies use containers to deploy applications many time a day

Why are containers popular now?

Docker makes it easy for everyone to work with containers

Provides a simple workflow around containers

Docker in detail

Docker separates applications from infrastructure using container technology

Similar to how Virtual Machines separates OS from the hardware it runs in

Docker vs VM

Benefits of Docker

Run apps locally in two steps

Easy to setup

Have a consistent environment across different machines

Consistency

Docker apps can be run anywhere, on any machine

Portable

Docker components

Docker daemon

Docker CLI

Workflow

From: https://speakerdeck.com/asm89/docker

Usual setup

Now

FROM ruby:2.3.1
RUN apt-get update
RUN apt-get install nodejs

RUN mkdir /myapp
WORKDIR /myapp

ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock

# FROM: Get image from docker index

# RUN: Run commands inside container

Dockerfile

db:
  image: postgres:9.5.0
  volumes:
    - .:/tmp/data/
web:
  build: .
  command: bundle exec rails s -p 3000 -b '0.0.0.0'
  volumes:
    - .:/code
  ports:
    - "3000:3000"
  links:
    - db

# Rails server

# Share this folder 

# Get Postgres image

docker-compose.yml

# Build project
docker-compose build

Docker commands

# Run project
docker-compose up

Docker hub

Demo

https://30k.co/1of

What's Docker

By pablovallejo

What's Docker

Introduction to Docker

  • 1,267