Tuesday, April 11, 2017

Docker Quick

Docker on ORACLE Linux:
====================
1> Docker Installation

yum update
yum list docker
yum install docker-engine


sh-4.1# cat /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/oraclelinux/6/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
sh-4.1#


2> Docker quick installation

$ curl -fsSL https://get.docker.com/ | sh

This script adds the docker.repo repository and installs Docker.

3> service docker start


Docker on Debian/ Jessie (Goole cloud instance):
====================================

Docker on Debian (Jessie) Install :
=========================

https://store.docker.com/editions/community/docker-ce-server-debian?tab=description

sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

  sudo add-apt-repository \
         "deb [arch=amd64] https://download.docker.com/linux/debian \
         $(lsb_release -cs) \
         stable"

sudo apt-get update

sudo apt-get -y install docker-ce

sudo apt-get -y install docker-ce
Start Docker:

sudo systemctl start docker

sudo docker run hello-world

# -i : interactive
# -t : tty (terminal)
sudo docker run -it ubuntu bash


Steps:
======

surinder_kumar_432@instance-2:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0ef2e08ed3fa        6 weeks ago         130 MB
hello-world         latest              48b5124b2768        2 months ago        1.84 kB
surinder_kumar_432@instance-2:~$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

surinder_kumar_432@instance-2:~$

docker run :
============

surinder_kumar_432@instance-2:~$ sudo docker run -it debian /bin/bash
Unable to find image 'debian:latest' locally
latest: Pulling from library/debian
6d827a3ef358: Pull complete
Digest: sha256:72f784399fd2719b4cb4e16ef8e369a39dc67f53d978cd3e2e7bf4e502c7b793
Status: Downloaded newer image for debian:latest
root@0bd213c180b3:/# uname -a
Linux 0bd213c180b3 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
root@0bd213c180b3:/#

surinder_kumar_432@instance-2:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
debian              latest              8cedef9d7368        2 weeks ago         123 MB
ubuntu              latest              0ef2e08ed3fa        6 weeks ago         130 MB
hello-world         latest              48b5124b2768        2 months ago        1.84 kB
surinder_kumar_432@instance-2:~$

e.sh :
=====

$ cat e.sh

surinder_kumar_432@instance-2:~$ cat e.sh
#!/bin/sh

echo "Hello Surinder"
surinder_kumar_432@instance-2:~$

$

Dockerfile:
===========

surinder_kumar_432@instance-2:~$ cat Dockerfile

FROM debian:latest

COPY e.sh /

RUN chmod +x /e.sh

ENTRYPOINT /e.sh
surinder_kumar_432@instance-2:~$


docker build:
=============

surinder_kumar_432@instance-2:~$ sudo docker build -t debian:e .
Sending build context to Docker daemon 13.82 kB
Step 1/4 : FROM debian:latest
 ---> 8cedef9d7368
Step 2/4 : COPY e.sh /
 ---> Using cache
 ---> 8aff336abaeb
Step 3/4 : RUN chmod +x /e.sh
 ---> Using cache
 ---> f7f6b59f4a42
Step 4/4 : ENTRYPOINT /e.sh
 ---> Using cache
 ---> bbfe1f4cf219
Successfully built bbfe1f4cf219
surinder_kumar_432@instance-2:~$

docker images:
==============
surinder_kumar_432@instance-2:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
debian              e                   bbfe1f4cf219        47 seconds ago      123 MB
debian              latest              8cedef9d7368        2 weeks ago         123 MB
ubuntu              latest              0ef2e08ed3fa        6 weeks ago         130 MB
hello-world         latest              48b5124b2768        2 months ago        1.84 kB
surinder_kumar_432@instance-2:~$


surinder_kumar_432@instance-2:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
debian              e                   bbfe1f4cf219        About a minute ago   123 MB
debian              latest              8cedef9d7368        2 weeks ago          123 MB
ubuntu              latest              0ef2e08ed3fa        6 weeks ago          130 MB
hello-world         latest              48b5124b2768        2 months ago         1.84 kB
surinder_kumar_432@instance-2:~$

docker run:
===========

surinder_kumar_432@instance-2:~$ sudo docker run bbfe1f4cf219
Hello Surinder
surinder_kumar_432@instance-2:~$ sudo docker run -t bbfe1f4cf219
Hello Surinder
surinder_kumar_432@instance-2:~$ sudo docker run -it bbfe1f4cf219
Hello Surinder
surinder_kumar_432@instance-2:~$

No comments:

Post a Comment