Docker commands

What is Docker?

Estimated read time: 8 minutes

Wondering about what is docker and its benefits for developers?

Read on as we will cover them in full here.

Whether you‘re a CTO, technical lead or senior developer tasked with looking after a team, we‘re sure you‘ll find some valuable nuggets of information. 

After you‘ve finished reading this article, you‘ll have an awareness of what Docker is, the benefits of implementing it and be more informed about the related docker terms.

What is Docker?

In a nutshell, Docker removes the endless environmental configuration conflicts that can occur when collaborating with co-workers and helps to reduce those “it works in my machine” conversations.

It can be used to run and maintain applications, side by side, in isolated containers.  Software development teams can use it to complement their existing agile and DevOps delivery practices and as a platform, Docker can run securely on Linux and Windows environments.

From a software developer‘s perspective, there are many benefits to implementing Docker in your development lifecycle, so let‘s explore some of these.

Benefits of Docker for Developers

Docker saves developers time and automates repetitive tasks often associated with provisioning new development environments which allow developers to focus on the task at hand, i.e. writing code.

Let‘s explore these in more detail.

Pre-configured environment

If you‘re a developer reading this, you‘ll no doubt be familiar with the numerous configuration tasks that are associated when onboarding a new developer. 

Docker saves you time by allowing you to define your operation system and any required software libraries in a dockerfile. Each time your environment is loaded, Docker ensures you have the relevant software and libraries needed by your application.

banner-img

Get a complimentary discovery call and a free ballpark estimate for your project

Trusted by 100x of startups and companies like

If you need to update the environment, all you need to do is update the container configuration and redeploy it.  This can save you time and money, naturally, these can also be shared with other developers and teams.

Source Controlled

As a developer, you will be checking code in/out of your source control repository all day.  You do the same with your dockerfile. One benefit of this is that your development environment is aligned with your code.

It works on my machine!

Most developers have experienced this at some point in their careers, you‘re working with another developer and need to integrate their class library or component with your codebase. You install and it doesn‘t work.  You let the developer know and the response is – “it works on my machine!”.

What ensues is double if not triple checking of environmental paths and settings to ensure they match. All of this takes time. Docker reduces if not removes this headache as all required libraries are encapsulated within containers that can be shared.

A little like VMs

A Docker container behaves in a similar fashion to that of virtual machines but runs a streamlined version of the operating system. 

Whilst the container still uses the host machine’s resources, you can restrict resources such as CPU, RAM, and HDD space. Unlike virtual machines, however, a Docker container will just use the resources it needs, thereby, allowing you to manage several containers on one host.

Continuous Integration (CI)

Continuous integration (or continuous delivery) on platforms such as Visual Studio Team Services allows you to trigger a build based on check-ins or run suites of automated tests.

In the Visual Studio Marketplace, you can download a Docker extension that allows you to factor in Docker images to your existing agile DevOps CI workflow.

Microsoft .NET, Visual Studio Code, and Docker Extension

The Docker extension makes it easy to build your applications with Visual Studio and Visual Studio Code, just some of the benefits include:

  • Automatic Dockerfile and docker-compose.yml file generation.
  • Syntax highlighting and hover tips for docker-compose.yml and Dockerfile files.
  • IntelliSense (completions) for Dockerfile and docker-compose.yml files.
  • Linting (errors and warnings) for Dockerfile files.
  • Command Palette (F1) integration for the most common Docker commands (e.g. Build, Push).
  • Explorer integration for managing Images and Containers.
  • Deploy images to the cloud by running the Azure CLI in a container.

Security

From a security point of view, Docker ensures that applications that are running on containers are segregated and isolated from each other. No Docker container can “bleed” into processes running inside another container.

From an architectural point of view, each container gets its own set of resources ranging from processing to network stacks.

Take me to the cloud

Most of the major cloud computing providers such as Amazon, Google and Microsoft have all added support for Docker. For example, Docker containers can be run on an Amazon EC2 instance, or Google Compute Engine instance.

Microservices

The days of monolithic applications are coming to an end and developers are adopting service-oriented architecture and loosely coupled services that can be implemented and deployed independently of each other. 

These building blocks can be assembled to form entire applications. One could say we‘ve entered the API economy from a software development perspective.

With Docker, you can select the best tool or stack for each service, the platform lets you isolate any potential conflicts and mitigates any risk of entering DLL hell. 

Containers can be easily shared, deployed, updated independently and scaled instantly – regardless of the other services that make up your application.

The end to end security features help you implement and run services that execute on a “least privilege” model. What this means is that services only get access to the resources they need – just at the right time.

In a nutshell

When an application is “dockerized”, all this complexity is encapsulated into containers that are easy to build, share and run.  No more time spent on installing 3rd party software and installing data access components or explaining onboarding procedures to new starts.

Dockerfiles can make your development process simpler, any dependencies are pulled as packaged Docker Images and anyone with Docker and an editor installed can build and debug the application quickly. 

What all of this means is that you‘re able to reduce the time it takes to ship your software products thereby saving you time and money.

Next, look at some key terms that you will come across while working with docker.

What is a Docker Container?

Containers are a way to bundle software in a format that can be run in an isolated manner on a shared operating system.

Containers shouldn‘t be confused with VMs however, Containers don‘t contain an Operating System installation.  They only contain libraries and settings required to make the software application run as expected – regardless of where the application is deployed.

They are available for both Linux and Windows-based apps and “containerized” software will always run the same, regardless of the environment.

Hire expert developers for your next project

62 Expert dev teams,
1,200 top developers
350+ Businesses trusted
us since 2016

Containers isolate software from its surroundings, for example, differences between development and staging environments, and help reduce conflicts between teams running different software on the same infrastructure.

Source: www.docker.com
A schematic representation of a Docker Container

Are Containers just like Virtual Machines?

You could be forgiven for thinking that Containers are just like Virtual machines, consider the following diagrams which illustrate the differences between a Container and Virtual Machine:

An illustration of the differences between a Container and Virtual Machine

The observant amongst you will have noticed that a Docker container doesn‘t contain the operating system.

The following descriptions below, from the official Docker site, contain a further explanation of the differences:

Virtual Machine
Virtual machines run guest operating systems—note the OS layer in each box. This is resource-intensive, and the resulting disk image and application state is an entanglement of OS settings, system-installed dependencies, OS security patches, and other easy-to-lose, hard-to-replicate ephemera.

Container
Containers can share a single kernel, and the only information that needs to be in a container image is the executable and its package dependencies, which never need to be installed on the host system. These processes run like native processes, and you can manage them individually by running commands like docker ps—just like you would run ps on Linux to see active processes. Finally, because they contain all their dependencies, there is no configuration entanglement; a containerized app “runs anywhere.”

To find out more about the topic, check out this comparison between Docker and Kubernetes, which is another containerization platform.

What is a Docker Layer?

A Docker Layer (or image layer) is a modification to a Docker Image or an intermediate image.  Every command you invoke (COPY, RUN, FROM, etc.) in your Dockerfile causes the previous image to change thereby creating a new layer.

For example, consider the following:

FROM ubuntu                            #This has its own number of layers

say “X”MAINTAINER FOO          #This is one layer

RUN mkdir /tmp/foo                  #This is one layer

RUN apt-get install vim              #This is one layer

This would create a final image where the total number of layers will be X+3.  Another way to think of this is as if you were staging changes when using Git.

What are Docker Images?

An Image is the “template” that contains the application and any associated binaries or libraries that are needed to build a Container. 

The image contains a series of Docker instructions. Or, see the following description from the official www.docker.com site:

An image is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the code, a runtime, libraries, environment variables, and config files.

Every package that gets added to the Image gets added as a new layer and the Container is basically the running instance of the Image.

What is a Dockerfile?

We mentioned dockerfile in that last section, you might be wondering what that is now! The simplest explanation was taken from the official Docker documentation site.

Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Here is an example of the structure of a Dockerfile:

Hire expert developers for your next project

Trusted by

# Comment
INSTRUCTION arguments

The instruction is not case-sensitive. However, convention (like SQL statements) is for them to be UPPERCASE to distinguish them from arguments more easily.  Here is an example of a simplistic Dockerfile

# Comment
RUN echo ‘we are running some # of cool things’

Some Basic Commands

Now that you have a basic understanding of what Docker is about and what some of the key components and concepts are, it‘s time to discuss some basic Docker commands RUN, CMD, and ENTRYPOINT.

If you were to condense these commands into one sentence for each, you could say the following about each of them:

RUN
With this, you can execute commands. You need to specify an image to derive the container from.  This command is mainly used for installing a new package. 

CMD
CMD sets the default command (and/or parameters) whilst also allowing you to overwrite commands, pass in or bypass default parameters via the command prompt when Docker runs. 

ENTRYPOINT
This command ultimately allows you to identify which executable should be run when a container is started from your image.

You can find more detailed information regarding parameters on the Docker documentation site here.

The Future for Docker

It‘s hard to say what the future holds for Docker as it‘s a relatively young software project and other companies such as Vagrant are starting to offer rival container services.  That said, competition can be healthy and often results in better products and services for the community.

Summary

In this blog post, we‘ve run through Docker, we‘ve discussed Containers, Images, Dockerfiles and the benefits of using Docker for developers.

To learn more about how Docker stacks up against Vagrant, check out this blog post.

We hope you‘ve enjoyed reading this article and that it‘s given you an insight as to how Docker could benefit your existing projects or processes.

If you want to partner with experienced software developers to work on your next software development and deployment project, DevTeam.Space can provide you with vetted and managed developers from its field-expert community of software developers.

Write to us your initial project requirements and one of our managers will get in touch with you for further assistance. 

If you want to explore Docker or learn more, you can find more information at the following URLs:

Main Docker Site
https://www.docker.com/

Running a .NET Core app in a Docker container
https://raygun.com/blog/net-core-docker-container/

.NET and Docker
https://www.hanselman.com/blog/NETAndDocker.aspx

https://blogs.msdn.microsoft.com/dotnet/2017/05/25/using-net-and-docker-together/

Docker and Linux Containers
https://www.infoworld.com/article/3204171/linux/what-is-docker-linux-containers-explained.html

Best Practices for writing Dockerfiles
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

Frequently Asked Questions

What is Docker?

Docker is a PaaS service that uses OS-level virtualization to allow applications to be run and tested.

How do I run a command in Docker container?

Use the following command line in Docker exec -it

Is Docker free?

Docker CE is free to use and includes help support.


Alexey

Alexey Semeney

Founder of DevTeam.Space

gsma fi band

Hire Alexey and His Team To Build a Great Product

Alexey is the founder of DevTeam.Space. He is award nominee among TOP 26 mentors of FI's 'Global Startup Mentor Awards'.

Alexey is Expert Startup Review Panel member and advices the oldest angel investment group in Silicon Valley on products investment deals.

Hire Expert Developers

Some of our projects

Photofy

5M+

Users

United States

App Store iOS Mobile QA

An app to help 5M+ users create beautiful and professional photos with ease.

Details
NewWave AI

Academic

Papers

United States

All backend All frontend Design WordPress

A website to publish AI research papers with members-only access and a newsletter.

Details
Islandbargains

Shipping

Enterprise

FL, United States

Android iOS Java Mobile PHP Web Website

A complete rebuild and further extension of our client's web and mobile shipping system that serves 28 countries.

Details

Read about DevTeam.Space:

Forbes

New Internet Unicorns Will Be Built Remotely

Huffpost

DevTeam.Space’s goal is to be the most well-organized solution for outsourcing

Inc

The Tricks To Hiring and Managing a Virtual Work Force

Business Insider

DevTeam.Space Explains How to Structure Remote Team Management

With love from Florida 🌴

Tell Us About Your Challenge & Get a Free Strategy Session

Hire Expert Developers
banner-img
Get a complimentary discovery call and a free ballpark estimate for your project

Hundreds of startups and companies like Samsung, Airbus, NEC, and Disney rely on us to build great software products. We can help you too, by enabling you to hire and effortlessly manage expert developers.