Docker

By - scmGalaxy.com

About Me !

What We Will Learn

  • Linux Containers
    • Containers vs Virtuals Machines << FIGHT!!
    • Kernal namesspaces, cgroups, Capabilities...
  • Docker Engine
    • Execution Driver" libcontainer vs LXC
    • AUFS, OverlayFS, Device Mapper...
  • Docker Images
    • docker build | docker images | docker inspect
    • Union mounts, Layering, Dockerfile
  • Linux Containers
    • Docker start|stop|restart
  • Registers, Volumes, Networking

Prerequisites

You

- Basic Computer Knowledge

- Do not need to be Linux expert

Computer

- 1 -2 Linux Machine (Can be Vms)

Introducing Containers

What a waste

Solution - Virtualization

Virtualization is not perfect - Why?

s

Installing and Updating Docker

Client & Deamon

Install on Ubantu / Centos

Docker needs root

Install Docker on Ubantu using root

> apt-get update
> apt-get install -y docker.io
> service docker.io start

Install Docker on Redhar / Centos

> yum update
> yum install -y docker.io
> systemctl start docker.service

How to verify the version of docker?

> docker -v
> docker version

How to know Docker running?

> service docker.io status
> systemctl status docker.service

How to check details of Docker clients, deamon, containers, images, drivers, etc
> docker info

Skip Next 3 Slides

Update Docker version

> wget -q0- https://get.docker.com/gpg | apt-key add -
> echo deb http://get.docker.com/ubantu docker main > /etc/apt/sources.list.d/docker.list
> apt-get update
> apt-get install lxc-docker
> docker version

Adding Users to the Docker Group (Docker Config (Need root to work)

> docker run -it ubuntu /bin/bash (as a non-root)[ permission denied]
> cat /etc/group
> sudo gpasswd -a username docker
> cat /etc/group
> docker run -it ubuntu /bin/bash (as a non-root)
> logout
> login username

Setup Network to Docker Container

	> docker -v
> netstat -tlp
> service docker stop
> docker -H ipaddress:port -d &
> netstat -tlp
> export DOCKER_HOST="tcp://ipaddress:port" (from another machine)
> docker version

Major Docker Components

Images vs Container

An instance of an image is called container. If you start this image, you have a running container of this image. You can have many running containers of the same image. You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).

So a running image is a container.

Reference


http://stackoverflow.com/questions/23735149/docker-image-vs-container

Docker Images

docker pull -a fedora
Docker info
> docker run -it fedora /bin/bash
> docker images fedora
[ Images are stored under /var/lib/docker/<storage drivers>
						

Docker Containers

	> docker run -it ubuntu /bin/bash
> docker images
> docker ps
> docker attach <container_id>
> docker ps -a

Docker Registries and Repositories

hub.docker.com

Setup Jenkins Using Docker

Pull the official jenkins image from Docker repository.

> docker pull jenkins

Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.

> docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins
	Other commands
> docker run -p 8080:8080 jenkins
> docker create -v /var/jenkins_home --name jenkins-dv jenkins

> docker run -d -p 8080:8080 --volumes-from jenkins-dv --name myjenkins jenkins
> http://localhost:8080

> docker run -d -p 8080:8080 --volumes-from jenkins-dv --name myjenkins2 jenkins

Questions ??

Thanks!!!