Jumpstart on Docker

Jumpstart on Docker

Postby yiboj » Wed Mar 21, 2018 11:29 am

1. What is Docker

Starting from the company, Docker Inc., docker is the containerization technology that enables the creation and use of Linux® containers which are like extremely lightweight, modular virtual machines. Docker is a tool for packaging and shipping apps, it takes your code along with its dependencies and bundles it up and then seals it into a container and it's a service that distributes these containers across the internet and makes it searchable.

2. How to install Docker

Docker is available in two editions: Community Edition (CE) and Enterprise Edition (EE).
[*]Docker Community Edition (CE) is ideal for developers and small teams looking to get started with Docker and experimenting with container-based apps.
[*]Docker Enterprise Edition (EE) is designed for enterprise development and IT teams who build, ship, and run business critical applications in production at scale.

Docker CE and EE are available on multiple platforms including linux, Mac and MS window, on cloud and on-premises. Please refer to the docker office site for installation details (https://docs.docker.com/install/).

Here is the test for the installation using popular hello world legacy:
Code: Select all
$ 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.
    (amd64)
 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/


3. What is Docker image

Docker all starts with image. An image is the file that makes up just enough of the operating system to do what you need to do. It is composed of layers of filesystems and the most important is that an image is ready only.

You can see all your images using the following command:
Code: Select all
$ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
ubuntu                                 latest              f975c5035748        2 weeks ago         112.4 MB
hello-world                            latest              f2a91732366c        4 months ago        1.848 kB


4. What is Docker container

Containers is the running instance of an image. It is started with the docker run command, like this:
Code: Select all
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG...]


Let's use the Ubuntu image to start a new container and try to run some shell commands in the container:
Code: Select all
$ docker run -it ubuntu /bin/bash
root@93a8d4f5d7a6:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@93a8d4f5d7a6:/# touch MY_FILE
root@93a8d4f5d7a6:/# ls
MY_FILE  bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@93a8d4f5d7a6:/#



5. How to search and download image

Docker Hub is a cloud-based registry service which allows you to build and share images. To explore Docker Hub, you need to create an account by following the directions in Docker Hub site. After you get the free Docker Id, you can login to Docker Hub using the following command:
Code: Select all
$ docker login


You may start search or explore the public repositories and images from Docker Hub in two ways. You can “Search” from the Docker Hub website, or you can use the Docker command line tool to run the docker search command. For example if you were looking for an ubuntu image, you might run the following command line search:
Code: Select all
$ docker search ubuntu


After you find the ubuntu image, pull or download the image with the following command:
Code: Select all
$ docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
22dc81ace0ea: Pull complete
1a8b3c87dba3: Pull complete
91390a1c435a: Pull complete
07844b14977e: Pull complete
b78396653dae: Pull complete
Digest: sha256:e348fbbea0e0a0e73ab0370de151e7800684445c509d46195aef73e090a49bd6
Status: Downloaded newer image for ubuntu:latest


Here is the list of references for you to explore:
1. Docker Hub
2. Docker Documentation
3. Get Started with Docker
yiboj
 
Posts: 88
Joined: Mon Mar 30, 2015 11:22 am

Return to Data Recipes