Docker

is a platform for developers and sysadmins to develop, deploy, and run applications with containers.

Images and containers

A container is launched by running 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.

Containers and virtual machines

A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.

Test Docker installation

$ docker run hello-world

List images

$ docker image ls
$ git checkout b21a887

Build our image

$ docker build --tag=nodeapp .

See our local image

$ docker image ls

Run our app!

$ docker run -p 4000:3000 nodeapp

Detached mode

$ docker run -d -p 4000:3000 nodeapp

How do we stop it?

$ docker container ls
...
$ docker container stop <container-id>

You can now share or publish your image!

docker-compose

version: "2"
services:
  api1:
    image: api1
    ports:
      - "4000:3000"
    build:
      context: .
      dockerfile: Dockerfile
    command: npm run start
    volumes:
      - .:/app
      - /app/node_modules

About services

$ git checkout master
...
$ docker-compose build
...
$ docker-compose up

Thank you!

Docker workshop

By Gabriel Miranda

Docker workshop

Workshop for MXP

  • 206