Make you life easy!

Use                            =)

Dev-Talk 15min @Mediaresponse

Get Start

  • Install all dependences
  • choose your operational system
  • have fun =)

Operational system

CENTOS

#$ sudo yum install docker
#$ sudo service docker start
#$ sudo chkconfig docker on 
#$ docker info
#$ docker version

UBUNTU >= 14-10

#$ sudo apt-get install -y docker.io

#$ docker info
#$ docker -v 

OSX

https://www.docker.com/toolbox

Basic commands

Running fist container

$ docker ps -a
$ docker run grumpy:cat 
$ docker ps
$ docker ps -a
$ docker run -it grumpy:cat /bin/bash
$ ls
$ pwd
$ hostname

List images

$ docker images

 

List container running

$ docker ps -a

 

Pull someone image

$ docker pull name-repo/tag

Exemple: Docker images

Create a container

Dockfile

FROM          ubuntu:latest
MAINTAINER    Thiago Zilli <tzilli@corp.mediaresponse.com>

RUN apt-get -y install apache2 

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

docker build --no-cache -t thiagozs/grumpy:thecat .

docker build -t thiagozs/grumpy:thecat .

Generate image

Start/Stop a container

Running a image

docker run -d -p 1883:1883 --restart=always -t thiagozs/grumpy:thecat

Stop a image

docker stop container-id

Start a image

docker start container-id

-p |--port  == 1883:1883

Parameters

local     container

tcp / udp - others

Exemple: Start/Stop/Logs

Bash is your friend

Stop all instances (Up)

$ sudo docker rm $(sudo docker ps -a | grep Up | awk '{print $1}')
Remove all instances stoped (Exited)

$sudo docker rm $(sudo docker ps -a | grep Exited | awk '{print $1}')
Remove empty instances (none)

$sudo docker rmi -f $(sudo docker images | grep '<none>'| awk '{print $3}')
Remove all images except ubuntu image.

$sudo docker rmi -f $(sudo docker images | grep -v 'ubuntu' | grep -v 'IMAGE'| awk '{print $3}')

or zsh

Swarm container

Documentation

https://docs.docker.com/swarm/

More Tools

Dokku, Docker Compose, Krane, Jenkins, Rancher ... and others!

Docker-composer (swarm)

Commands

$docker-compose -f compose-example.yml up -d

Swarm - yml

... little more

$vim compose-example.yml

nginx:
  image: nginx
  links:
   - app1:app1
   - app2:app2
   - app3:app3
  ports:
   - "80:80"
app1:
  image: thiagozs/grumpy:thecat
app2:
  image: thiagozs/grumpy:thecat
app3:
  image: thiagozs/grumpy:thecat

 

Thank you.

Thiago Zilli Sarmento

twitter: @thiagozs

e-mail: thiago.zilli@gmail.com

November 27, 2015

DevTalk with Docker Containers

By Thiago Zilli Sarmento

DevTalk with Docker Containers

Simple docker presentation

  • 278