DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Step Into Serverless Computing
  • Mastering Go-Templates in Ansible With Jinja2
  • Replacing Apache Hive, Elasticsearch, and PostgreSQL With Apache Doris
  • SRE vs. DevOps

Trending

  • Step Into Serverless Computing
  • Mastering Go-Templates in Ansible With Jinja2
  • Replacing Apache Hive, Elasticsearch, and PostgreSQL With Apache Doris
  • SRE vs. DevOps
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Diving Into Docker

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.

Balaji Kandregula user avatar by
Balaji Kandregula
·
Aug. 06, 16 · Tutorial
Like (5)
Save
Tweet
Share
4.47K Views

Join the DZone community and get the full member experience.

Join For Free

"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.

Related Refcard:

Getting Started With Docker

Docker (software)

Opinions expressed by DZone contributors are their own.

Trending

  • Step Into Serverless Computing
  • Mastering Go-Templates in Ansible With Jinja2
  • Replacing Apache Hive, Elasticsearch, and PostgreSQL With Apache Doris
  • SRE vs. DevOps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: