Quick guide to Docker containers

What is Docker?

Here is the definition of the Docker site:

Setup Docker

Docker provides an easy setup package to get you started fast. Just follow the following instructions depending on you operating system.

Starting a docker container

Once you have completed the setup of Docker it is relatively straight forward to start your first container. Open a command line console and type the following command:

docker run hello-world
Figure 1 — Docker Pull Console Output

Important Docker commands

There are various Docker commands that you can use, but I found the below commands the most used commands in daily development practice.

# Pulls an image from the registry to your local machine.
docker pull hello-world
# Creates and starts a container in one operation.
docker run hello-world
# Lists containers that are running.
docker ps -a
# Show list of images on your machine.
docker images
# Delete a particular image.
docker rmi 2873hh433
# Delete every Docker image
docker rmi $(docker images -q)
# Delete every Docker containers
docker rm $(docker ps -a -q)

Create Dockerfile

What is a Dockerfile? Well, it is a configuration file to setup a custom container. Here is an example of setting up a Nodejs container:

FROM risingstack/alpine:3.3-v5.5.0-1.1.3COPY package.json package.json  
RUN npm install
COPY . .
EXPOSE 1337ENTRYPOINT ["npm","start"]
docker build -t test/test:latest .docker run --name nodetest -p 127.0.0.1:80:8080 -i test/test:latest /bin/sh

Latest Docker for Windows and Mac OS X release

Recently Docker has released a new Docker for Windows and Docker for Mac OS X beta to make it easier to work with Docker on Windows and Mac OS X. The Docker for Windows tool now works with HyperV so you don’t need Virtualbox anymore which was required with Docker Toolbox.

Figure 2 — Docker icon on desktop toolbar
Figure 3 — Docker up and running successfully

Summary

I hope this article helps you and gives you the confidence to get started with Docker. I challenge you to try and setup a basic three-tier application (Web Application Layer, Database Service Layer, and Cache Service Layer) with Docker.

--

--

Passion for Software and Enterprise Architecture. I like to play with Azure, Cloudflare and programming languages (C#, Rust, and JavaScript).

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cecil

Cecil

Passion for Software and Enterprise Architecture. I like to play with Azure, Cloudflare and programming languages (C#, Rust, and JavaScript).