Over a million developers have joined DZone.

Diving Into Docker

In this first article of in a series of Docker-related posts, we're going to cover the basics of getting Docker on your machine and setting up containers.

· Cloud Zone

Download this eBook outlining the critical components of success for SaaS companies - and the new rules you need to play by.  Brought to you in partnership with NuoDB.

"DevOps" and "microservices" are the buzz-words heard around enterprise social networks these days. These are not new among technology majors, such as Google, Facebook, and Netflix, etc., which have adjusted their technology and processes to deliver customer-facing applications at a rapid pace with minimal impact, but what are DevOps/Microservices?

DevOps and microservices have been around for a long time, but they were mostly limited to major technology players. But they're catching up among enterprises. Microservices represent the decomposition of traditional business systems into independently deployable services that perform the smallest unit of service, for example, "createCustomer," "updateCustomer," or "deleteCustomer." These services are delivered independently without any downtime to existing services. Besides that, the microservices architecture enables speed, safety, and scale.

On the other hand, DevOps emphasizes collaboration/communication between developers, and other IT professionals while automating software delivery and infrastructure changes. This is a disruptive shift in how customer solutions are delivered continuously.

The traditional software package deployment lifecycle includes hardware requisition, OS installation, and libraries installation before new product/features are deployed. The ever-growing dependency on infrastructure and administrators to deliver key functionality essentially kept most enterprises in the back seat.

Containers address these issues by "wrapping a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries — anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment."

Image title


Docker is an open-source project that "automates application deployment inside software containers, and provides an additional layer of abstraction and automation of operating-system-level virtualization on Linux." With the help of containers,  you can continuously deliver products (microservices) to customers.

Docker installation is pretty straightforward and the steps can be found on the Docker website.

Here are the common commands: 

Step

Command

Comments

Pull image

docker pull <<image_name>>:<<tag>>

docker pull ubuntu:15.10

Image will be pulled from Docker registry. Default tag value is latest, otherwise specific tag value should be included

Show images

docker images


Run image

docker run -i -t base_hadoop


Run image in background

docker run -d -P --name alluxio_test_1 alluxio_base


Display running images

docker ps –a

Displays container ID and name

Commit new image

docker commit -m "Comment" -a "Balaji" 9cdacf2fdf68 base_hadoop:v2

9cdacf2fdf68 — Current running image name


Base_hadoop:v2 — New image saved after making modifications to current image

Display container ID of exited containers

docker ps -a –q


Remove exited containers

docker rm $(docker ps -a -q)


Remove images

docker rmi <image_id>

docker rmi base_hadoop:v2


Copy files/folders to containers

docker cp 492428cbff6f:/opt/apache/hadoop-2.7.2-src/hadoop-dist/target/hadoop-2.7.2.tar.gz .


Execute command in running container

docker exec -ti <continer_id> /bin/bash

Useful for executing scripts from host


Docker provides features to create instruction set files (Dockerfiles), and build images based on the steps provided in the file, for example here is a sample instruction file:-
Image title


To create a docker image from the above instruction set, execute the following command:

docker build -t hadoop_sandbox

Execute the Docker run command to start an instance of a hadoop_sandbox image.

Enterprises typically start multiple containers. Docker-compose is a tool for defining and running multi-container Docker applications.

A sample Docker-compose file is given below to create multiple containers in a single execution.

docker-compose up –d (create and start containers).

docker-compose down (stop containers).

Image title

And you're on your way! Stay tuned for more, though. I will discuss the Alluxio Cluster setup using Docker in my next blog post.

Learn how moving from a traditional, on-premises delivery model to a cloud-based, software-as-a-service (SaaS) strategy is a high-stakes, bet-the-company game for independent software vendors. Brought to you in partnership with NuoDB.

Topics:
integration service ,tibco ,big data ,analytics ,big data analytics ,system integration

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}