This post will explain you what is the difference between docker image and docker container. Everything starts with the Dockerfile. The Dockerfile is the source code of the image.

Sample Dockerfile:

FROM ubuntu 
MAINTAINER thelinuxfaq 

RUN apt-get update 
RUN apt-get install –y nginx 
CMD ["nginx", "-g", "daemon off;"]

Dockerfile (Build) Image (Run) Container.

Dockerfile contains a set of Docker instructions that provisions your operating system

Docker image is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the application code, libraries, dependencies, and runtime.

Docker container is a running instance of a Docker image. In other words, a Docker container is an executable package that includes an application and all its dependencies, libraries, and runtime. You can create, start, stop, move, or delete a container using the Docker API or CLI.