Build Docker Container

Step 1: Download and install docker
110MB File

Step 2: Install image

$docker version

Step 3: Build docker image

Create following three files in empty folder.
File Name:

import sys
a = sys.argv[1]
b = sys.argv[2]
summ = int(a) + int(b)
print "sum is", summ

File Name: Dockerfile

# Use an official Python runtime as a base image. Get this version from local system with >python –version
FROM python:2.7.10

# Set the working directory to /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt. These are packages used in python script.
RUN pip install -r requirements.txt

# Make port 80 available to the world outside this container

# Define environment variable

# Run when the container launches
ENTRYPOINT [“python”, “”]

File Name: requirements.txt (empty)


>docker build -t calc .

>docker images
We should be able to see calc image

>docker run -p  calc 2 3
sum is 5


This is first simple docker image with Python code.
Every time we run, it creates image from cache and executes and dies.
Leaving many unused images, accumulating space.
>docker ps -a

We can see all past images, which are not existed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s