Category Archives: Docker

Blog migrated to Kubernetes

My subscription on the old hosting provider was expiring and it has been few years since I updated my blog. So I decided to migrate the blog and get rid of outdated infra.
I moved the blog to my infrastructure where I am running most of my applications on kubernetes and I decided this is the time to move this blog along with few others on kubernetes.

I will later create a post on how I did the migration and how my current infrastructure is.

Installing and using docker containers on Fedora 24

Recently a lot of organizations started to migrate their environment to microservices architecture using containerization tools such as docker. The advantage with container tools are it is fast, robust and gives you ability to control its behavior. I am going to show you some basics with docker containers.  But first we need to have it installed on the system. I am using Fedora 24 as my workstation. So this guide is written keeping in mind F24, but it should work on any linux flavors as well.

Installing docker

Docker website has very good documentation about installing and using docker which can be found here. To save time I will list the steps below.

First get docker repo file or create one with below contents in it.

name=Docker Repository

Now you can use dnf to install the docker engine.

#dnf install docker-engine

Next you need to start the docker service and enable it to run at boot.

#systemctl start docker
#systemctl enable docker.service

This will allow you to run docker containers as root user, but if you want to allow normal users to run containers then you need to add them to docker group. Make sure the users have sudo privilages as well.

#usermod -aG docker username

Running nginx container

Now that we have installed docker and want to deploy nginx container. There are few ways to do it, but for simplicity we will use nginx from docker repo. To get the nginx container image run below command.

$docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx

8ad8b3f87b37: Pull complete 
c6b290308f88: Pull complete 
f8f1e94eb9a9: Pull complete 
Digest: sha256:aa5ac743d65e434c06fff5ceaab6f35cc8519d80a5b6767ed3bdb330f47e4c31
Status: Downloaded newer image for nginx:latest

As we have not specified any tags it will default to latest and pull the latest nginx container image available from docker repository. You can verify the available images locally using below command.

$docker images
nginx latest 4a88d06e26f4 4 days ago 183.5 MB

Lets say we want to run the container in detached mode and want to forward port 8080 from our host to port 90 on nginx container run the below command.

$ docker run -itd --name web -p 8080:80 nginx:latest

Docker operations with container

We can check running docker containers using below command.

$ docker ps
8ab540475170 nginx:latest "nginx -g 'daemon off" 40 seconds ago Up 37 seconds 443/tcp,>80/tcp web

As you can see the port 8080 is forwarded to container port 80.

Let’s check nginx on local port to see if it works

$ curl localhost:8080
<!DOCTYPE html>
<title>Welcome to nginx!</title>
 body {
 width: 35em;
 margin: 0 auto;
 font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href=""></a>.<br/>
Commercial support is available at
<a href=""></a>.</p>

<p><em>Thank you for using nginx.</em></p>

If we want to stop the container just run below command.

$ docker stop web

And if you check no container should be running on the system now.

$docker ps

There are lots of things that could be done with docker containers but we would revisit it next time.