docker installation and basics

21
Walid Ashraf Researcher , Software Developer, Instructor about.me/WalidAshraf DOCKER INSTALLATION AND BASICS

Upload: walid-ashraf

Post on 15-Apr-2017

111 views

Category:

Technology


2 download

TRANSCRIPT

Walid AshrafResearcher , Software Developer, Instructor

about.me/WalidAshraf

DOCKER INSTALLATION AND BASICS

Docker - Walid Ashraf

Table of ContentsInstall Docker on Linux (Ubuntu)

Using Docker

Installing Docker On windows

Official Documentation for Ubuntuhttps://docs.docker.com/engine/installation/linux/ubuntulinux/

INSTALL DOCKER FOR

UBUNTU

Docker - Walid Ashraf

Prerequisites For Installation

Docker Requires 64-bit OS

Docker requires Linux kernel 3.10.0+

An Updated Version of you Package Manager (APT) Lists (Docker List)

AUFS Support

• Installation of Kernel Extra Image (Linux-image-extra-* kernel packages) for Ubuntu Trusty 14.04, and Xenial 16.04

Docker - Walid Ashraf

Installation

sudo apt-get install docker-engine

Start The Docker Service

• sudo service docker start

Test your first container:

sudo docker run hello-world

Docker - Walid Ashraf

Demo Time

https://docs.docker.com/engine/reference/c

ommandline/

USING DOCKER BEYOND THE

BASICS

Docker - Walid Ashraf

info, images, ps , pull

docker info

• States current client and daemon versions

docker images

• Lists Current Images at the machines

docker search

• Searches images on default repo

docker pull

• Downloads a image from the default repo.

docker ps

• List all containers at the machine

• -a : List all containers

Docker - Walid Ashraf

Run Command

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Set Container Name

• -name value

• Ex: docker run -name test HelloWorld

Start in interactive mode

• -i interactive mode

• -t Open tty

• Ex: docker run -it Ubuntu

Set Working dir

• Ex: docker run -w /home/ -i -t ubuntu pwd

Start in detached Mode

• Ex: docker run -d seqvence/static-site

Docker - Walid Ashraf

Run Command (Ports)

Port Mapping

• -p hostPort:ContainerPort

• -p hostIp:hostPort:ContainerPort

• -P all ports

• docker run -P seqvence/static-site

• docker run -d -p 80:80 --name webserver nginx

List Container Port

• docker port CONTAINER

• Ex: docker port webserver

Docker - Walid Ashraf

Run Command (Volumes)Docker Volumes allow a container to mount a directory to be shared between the host and container(s)

-v hostdirectory:containerdir

containerdi:ro allow that the mounted container to be read only

Ex: docker run -v /home/sharedfoo:/foo -it ubuntu bash

Ex: docker run -v /home/sharedfoo:/foo:ro -it ubuntu bash

Docker - Walid Ashraf

Other Import Commands

create

• Creates a docker containers with all options but doesn’t start it

start, pause, stop, rm

stats

• Gives a live preview of container utilization

exec

• Executes a command inside a container

• docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

• Ex: docker exec -d ubuntu_bash touch /tmp/execWorks

cp

• Copies data from container to host and vice versa

• Ex: docker cp container:/file1 /home/

• Ex: docker cp /home/file2 container:/

Using Docker Tool Box

Docker For windows

WINDOWS INSTALLATION

https://www.docker.com/products/docker-

toolbox

DOCKER TOOL BOX

Docker - Walid Ashraf

Using Docker toolbox

Toolbox includes these Docker tools:

• Docker Machine for running docker-machine commands

• Docker Engine for running the docker commands

• Docker Compose for running the docker-compose commands

• Kitematic, the Docker GUI

• a shell preconfigured for a Docker command-line environment

• Oracle VirtualBox

Prerequisites

• Docker Tool Box Requires 64 Bit Windows 7 or More

• Docker Requires H/W Virtualization ( A Virtual Box Requirement)

Install Tools

Docker - Walid Ashraf

Using TerminalUsing Docker quick start terminal to test any docker commands

Docker - Walid Ashraf

Using Kitematic

Kitematic is a GUI Docker Controller

You can search for any public images , create and Manager Containers.

Kitematic also automates advanced features such as managing ports and configuring volumes.

You can use Kitematic to change environment variables, stream logs, and single click terminal into your Docker container all from the GUI.

Checkout

• https://docs.docker.com/kitematic/userguide/

Docker - Walid Ashraf

Demo Time

https://docs.docker.com/docker-for-

windows/

DOCKER FOR WINDOWS

Docker - Walid Ashraf

InstallationPrerequisites

Windows runs on 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later).

The Hyper-V package must be enabled for Docker for Windows to work

Installation

Open Power shell and Use Docker command line

Docker - Walid Ashraf21