How to install and use Docker: Getting started


What is Docker?

Docker is the popular open source container engine to run distributed application.

Docker Containers (Layer of abstraction):

It allows a developer to package up an application and all of its part means the stack on which it runs, dependency that are associated with it into a standardized unit for software development. The application has all which it needs to run inside the container and what that means is the underlying host, the environment or the operating system on which it is running is completely abstracted from the application.

Why Docker?

  • Docker makes it incredibly easy to package and distribute software.
  • Docker builds and delivers tools that can make hard technology easier to use.
  • Docker (Build, Ship, Run) is to achieve agility and control for Development and IT Operations teams to build, ship, and run any app, anywhere:
    • Build- allows you to build an application in any language and using any tool chain.
    • Ship- lets you ship the “Dockerized” app and dependencies anywhere – to QA, teammates, or the cloud – without breaking anything.
    • Run- offers you the ability to deploy scalable services, securely and reliably, move between data centers and clouds, and more.

What can I use Docker for?

  • Deploying and scaling more easily- containers include the minimal runtime requirements of the application, reducing their size and allowing them to be deployed quickly.
  • Faster delivery of your applications- allows your developers to develop on local containers that contain your applications and services and then integrate into a continuous integration and deployment workflow.
  • Sharingyou can use a remote repository to share your container with others.
  • Suits for micro-services architecture- each micro service can be deployed without interrupting the other micro services and containers provide an ideal environment for service deployment in meaning of speed, isolation management, and life-cycle.

What are Docker core components?

  • Docker DAEMON – that runs on the host machine.
  • Docker CLIENT – used to interact with the DAEMON.

Note: The user does not directly interact with the daemon, but instead through the Docker client.

What is inside Docker ?

  • Docker Images- holds the environment and your application.
  • Docker registries- public and private repositories used to store docker images shared via Docker Hub or your own registry.
  • Docker containers- created from images, one can START, STOP, MOVE, DELETE these containers.
  • Docker File- automates image construction process.

How To Install Docker on Ubuntu ?

Docker requires a 64-bit installation regardless of your Ubuntu version. Additionally, your kernel must be 3.10 at minimum. The latest 3.10 minor version or a newer maintained version are also acceptable.

1. Update your droplet:

$ sudo apt-get update
$ sudo apt-get -y upgrade

2. Make sure aufs support is available:

$ sudo apt-get install linux-image-extra-`uname -r`

3. Next, add the Docker repository key to your local Apt keychain:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com \ --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

4. Add the Docker repository to your list of repositories:

$ sudo sh -c "echo deb http://get.docker.io/ubuntu docker main \
> /etc/apt/sources.list.d/docker.list"

5. Then update the repository with the new addition:

$ sudo apt-get update

6. Finally, download and install docker:

$ sudo apt-get install docker-engine

7. Start the docker daemon.

$ sudo service docker start

8. Verify docker is installed correctly.

$ sudo docker run hello-world

How To Use Docker ?

Once you have docker installed, you can use the below commands to use it.

Ask docker for a list of all available commands:

$ sudo docker

1. Working with Images

  • Searching for a docker image:
    $ sudo docker search [image name]
  • Pulling an docker image:
    $ sudo docker pull [image name]
  • Listing docker images:
    $ sudo docker images
  • Committing changes to docker image:
    $ sudo docker commit [container ID] [image name]
  • Pushing docker image:
    $ sudo docker push [username/image name]  
    

2. Working with Containers

  • Listing all current containers:
    $ sudo docker
  • Creating a New Container: To create a new container, you need to use a base image and specify a command to run.

    $ sudo docker run [image name] [command to run]
  • Running a container:  Using the ID of a container, you can run it.

    $ sudo docker run [container ID]
  • Stopping a container: To stop a container’s process from running:
    $ sudo docker stop [container ID]
  • Deleting a container: Using the ID of a container, you can delete one with rm.
    $ sudo docker rm [container ID]

 

This entry was posted in Scala and tagged , , , , , . Bookmark the permalink.

2 Responses to How to install and use Docker: Getting started

  1. Pingback: How to install and use Docker: Getting started | dotnetask

  2. Pingback: How to install and use Docker: Getting started – prashantgoel6

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s