Slide 1
Most trusted JOB oriented professional program
DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2
DevOps to DevSecOps – Learn the evolution
DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2
Get certified in the new tech skill to rule the industry
Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2
Master the art of DevOps
Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2
Gain expertise and certified yourself
Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3
Learn and get certified
AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow
next arrow

Docker Tutorials: Image – Dockerfile to Build a Fedora Container

The administrator may decide that building interactively is tedious and error-prone. Instead the administrator could create a Dockerfile that layers on the Apache Web server and the web site content in one build.


The docker run command must specify an IMAGE to derive the container from. An image developer can define image defaults related to:

  • detached or foreground running
  • container identification
  • network settings
  • runtime constraints on CPU and memory

Detached vs foreground
When starting a Docker container, you must first decide if you want to run the container in the background in a “detached” mode or in the default foreground mode:

Detached (-d)

To start a container in detached mode, you use -d=true or just -d option. By design, containers started in detached mode exit when the root process used to run the container exits.

Do not pass a service x start command to a detached container. For example, this command attempts to start the nginx service.

$ docker run -d -p 80:80 my_image service nginx start

This succeeds in starting the nginx service inside the container. However, it fails the detached container paradigm in that, the root process (service nginx start) returns and the detached container stops as designed. As a result, the nginx service is started but could not be used.

Instead, to start a process such as the nginx web server do the following:

 $ docker run -d -p 80:80 my_image nginx -g 'daemon off;'


In foreground mode (the default when -d is not specified), docker run can start the process in the container and attach the console to the process’s standard input, output, and standard error.

It can even pretend to be a TTY (this is what most command line executables expect) and pass along signals.

You can specify to which of the three standard streams (STDIN, STDOUT, STDERR) you’d like to connect instead, as in:

$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash

For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process. -i -t is often written -it as you’ll see in later examples.


Create one mysite.tar with some dummy index.html and images.

A good practice is to make a sub-directory with a related name and create a Dockerfile in that directory. E.g. a directory called mongo may contain a Dockerfile for a MongoDB image, or a directory called httpd may container an Dockerfile for an Apache web server. Copy or create all other content that you wish to add to the image into the new directory. Keep in mind that the ADD directive context is relative to this new directory.

# mkdir httpd  
# cp mysite.tar httpd/ 

Create the Dockerfile in the httpd directory. This Dockerfile will use the same base image as the interactive command fedora:

FROM fedora 
MAINTAINER Rajesh Kumar email:

# Update the image with the latest packages (recommended) 
RUN yum update -y; yum clean all

# Install Apache Web Server 
RUN yum install -y httpd; yum clean all

# Add the tar file of the web site 
ADD mysite.tar /tmp/

# Docker automatically extracted. So move files to web directory 
RUN mv /tmp/mysite/* /var/www/html 
ENTRYPOINT [ "/usr/sbin/httpd" ] 

Build this Dockerfile from the new httpd directory and run it:

# docker build --rm -t newsite httpd/   # docker run -d -P newsite 

The container build process builds a series of temporary image layers based on the directives in the Dockerfile. These temporary layers are cached so if you make modifications to the content tarball, it won’t completely rebuild and update the Fedora image. Since each directive is a new layer, you could reduce the number of layers by combining the RUN yum directives into a single RUN directive:

RUN yum -y install httpd && yum -y update; yum clean all 

Planning your layers will determine how many layers need to be recreated on each build of the container.

Rajesh Kumar