0% found this document useful (0 votes)
9 views

CC Lab

The document is a record notebook for students at the Knowledge Institute of Technology, detailing various experiments conducted in the CCS335 Cloud Computing Laboratory during the 2024-2025 academic year. It includes procedures for installing software such as VirtualBox, Google App Engine, and CloudSim, along with executing programming tasks and simulations. Each experiment is aimed at enhancing students' practical skills in cloud computing technologies.

Uploaded by

2k22it39
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CC Lab

The document is a record notebook for students at the Knowledge Institute of Technology, detailing various experiments conducted in the CCS335 Cloud Computing Laboratory during the 2024-2025 academic year. It includes procedures for installing software such as VirtualBox, Google App Engine, and CloudSim, along with executing programming tasks and simulations. Each experiment is aimed at enhancing students' practical skills in cloud computing technologies.

Uploaded by

2k22it39
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

KNOWLEDGE INSTITUTE OF TECHNOLOGY

(An Autonomous Institution)


(Accredited by NAAC & NBA, Approved by AICTE, New Delhi and Affiliated To Anna University, Chennai)

KAKAPALAYAM (PO), SALEM – 637 504

RECORD NOTE BOOK


Register Number

Certified that this is the bonafide record of work done by

Selvan/Selvi……………………………………………………..…………………………… of the……….

Semester ……………………………………………………..…………………………………. branch

during the academic year 2024-2025 in the CCS335 Cloud Computing Laboratory

Staff – In charge Head of the Department

Submitted for the University practical Examination on .................................................. Internal

Examiner External Examiner


CONTENTS

Mark
EX.NO DATE Name of the Experiment PageNo. Signature
Awarded

Install Virtualbox/VMware Workstation


1 with different flavours oflinux or
windows OS on top of windows7 or 8
Install a C compiler in the virtual
2 machine created usingvirtual box
and execute Simple Programs
Install Google App Engine. Create hello
world app and othersimple web
3
applications using python/java.

Use GAE launcher to launch the web


4 applications.

Simulate a cloud scenario using


CloudSim and run ascheduling
5 algorithm that is not present in
CloudSim.

Find a procedure to transfer the


6
files from one virtualmachine to
another virtual machine

Install Hadoop single node cluster and run


7a simple applicationslike wordcount

Run simple applications like Hadoop


7b wordcount MapReduceProgram

Creating and Executing Your First


8 Container Using Docker

9 Run a Container From Docker Hub


Ex. No : 1
Install Virtualbox/VMware Workstation with different flavours of
Date: linux or windows OS on top of windows7 or 8

AIM:

To Find the procedure to Install Virtualbox/VMware Workstation with different flavours


of linux or windows OS on top of windows7 or 8.

PROCEDURE:

Step 1: Download and install Oracle VM Virtualbox in Windows platform (Host OS)

https://www.virtualbox.org/

Step 2: Visit the page http://www.ubuntu.com/download/ubuntu/download

Step 3: Choose the Latest version of Ubuntu and 32-bit and click “Start Download”

Step 4: Run VirtualBox by double-clicking the icon and Click “New” button on the top
left corner

Step 5: Click “Continue” on the pop-up window and Type VM name, select Linux for
the OS and choose “Ubuntu” for the version

Step 6: Choose the amount of memory to allocate (choosing between 512 MB to 1024
MB) and Click Continue or Next

Step 7: Choose create a new virtual hard disk and Click Continue or Next

Step 8: Choose VDI (VirtualBox Disk Image) and Click Continue or Create

Step 9: Install Ubuntu OS in VM and when finished, click Restart and press Enter

Step 5: Open terminal and update all packages

>sudo apt-get install update


OUTPUT:
RESULT:

Thus the installation procedure for Virtualbox with different flavours of linux or windows
OS on top of windows7 was executed successfully.
Ex. No : 2
Install a C compiler in the virtual machine created using
Date : virtual box and execute Simple Programs

AIM:

To install a C compiler in the virtual machine created using virtual box and execute a
Simple Programs

PROCEDURE:

Step 1: Open Oracle VM Virtualbox and Run Ubuntu OS

Step 2: Open Terminal and install gcc compiler

>sudo apt-get install gcc

Step 3: Check the gcc version you have installed

>gcc –version
Step 4: Open the editor

>sudo nano hello.c

Step 5: Type sample C Program

#include<stdio.h>
main()
{
printf("Hello World\n");
}

Step 5: Save the file by clicking Ctrl+X then type Y

Step 6: Type ls command on Terminal to see all files under current folder

Step 7: To Compile the program type

>sudo gcc hello.c

Step 8: To run the program type

>./a.out

Step 8: If you see “Hello World” on the next line, you just successfully executed your
First C program!
OUTPUT:
RESULT:

Thus the installation of a C compiler in the virtual machine created using virtual box and
execution of a Simple Programs was executed successfully.
Ex. No : 3
Install Google App Engine. Create hello world app and other
Date : simple web applications using python/java.

AIM:

To Install Google App Engine, Create hello world app and other simple web applications
using python/java.

PROCEDURE:

Step 1: Download and install Python

https://www.python.org/downloads/

Step 2: Download and Install Google Cloud SDK

https://cloud.google.com/sdk/docs/install

Step 3: Create your hello world application using python program

print 'hello world'

Step 4: create a file called app.yaml

runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /
script: text.py

Step 5: Open Google Cloud SDK Shell and run

>google-cloud-sdk\bin\dev_appserver.py “C:\Users\Administrator\Desktop\cc”

Step 6: To open Web browser and run

http://localhost:8080/
OUTPUT:
RESULT:

Thus the installation of Google App Engine, Create hello world app and other simple web
applications using python was executed successfully.
Ex. No : 4
Use GAE launcher to launch the web applications
Date :

AIM:
To Use GAE launcher to launch the web applications.

PROCEDURE:

• Enable App Engine in a Google Cloud project.


• Clone a sample "Hello World!" app.
• Test the app in your development environment.
• Deploy the app to App Engine.
• View and monitor the app.
Step 1: Enable App Engine in a Cloud project
Select a project, or create a new one
Step 2: To open Cloud Shell, click Cloud Shell
Step 3: Goto Google Cloud Platform (GCP) menu and click APIs & Services then Library,
Search App Engine Admin API and Click Enable
Step 4: In Cloud Shell console type (Enable App Engine)
> gcloud app create
Step 5: If an authorization window appears, click Authorize
Step 6: When prompted, choose a region that's closest to you
The process is complete when you get this message:
Success! The app is now created
Step 9: Again Goto GCP – APIs & Services Dashboard check Your App Engine application
has been created
Step 10: Clone a sample app
Instead of creating a new app, clone the sample "Hello, world" app from GitHub:
>git clone https://github.com/GoogleCloudPlatform/pythonn-docs-sample
The app consists of:
main.py, a Python file with the function that responds to requests with "Hello World!"
requirements.txt, a text file listing package dependencies that the app requires
app.yaml, an App Engine configuration file with the minimum required settings

Step 11: Test the app before deploying it


To open a shell in Cloud Shell Editor, click the Terminal menu and select New
Terminal.
> cd \python-docs-samples/appengine/standard_python3/hello_world
> pwd
> ls
Step 12: To check the contents of a file
> cat main.py
> cat app.yaml
Step 13: To create and activate a virtual environment in which to test your app, use the
following commands:
> virtualenv --python python3 ~/envs/hello_world
> source ~/envs/hello_world/bin/activate
> pip install -r requirements.txt
Step 13: To run your app, use the following command:
> python main.py
When the app is running, the output in Cloud Shell shows the following:
Running on http://127.0.0.1:8080
Step 14: Deploy the app, In Cloud Shell, configure gcloud to use your project:
> gcloud config set project cc-lab-ex4
Step 15: Deploy your app
> gcloud app deploy
If you are prompted, "Do you want to continue?", type Y.
When this process is finished, the output shows the following:
Deployed service [default] to https://cc-lab-ex4.ue.r.appspot.com
Step 16: View and monitor the app
Visit the deployed app at its default URL: cc-lab-ex4.ue.r.appspot.com.
To view the App Engine dashboard, in the Cloud Console navigation menu select
You have successfully tested an app, deployed it, and used the Console to monitor the
app's use of Cloud resources.
Step 16: Clean up
In the App Engine navigation menu, click Settings.
Click Disable Application.
Or you can delete the project that you created
OUTPUT:
RESULT:
Thus the Google App Engine launcher is used to launch web applications using python
was executed successfully.
Ex. No : 5
Simulate a cloud scenario using CloudSim and run a
Date : scheduling algorithm that is not present in CloudSim

AIM:
To simulate a cloud scenario using CloudSim and run a scheduling algorithm that is not
present in CloudSim.
PROCEDURE:
• Java Installation and set path variable.
• Download CloudSim and additional jar file
o Download CloudSim 3.0.3
o Download commons math 3 jar file
• Eclipse IDE Installation
• Run CloudSim in Eclipse
o Put up commons-math-3.3.6.1.jar file into jar folder of CloudSim3.0.3
o Bulid a new java project with CloudSim3.0.3

Step 1: Download and Install java JDK


https://www.oracle.com/java/technologies/downloads/#jdk17-windows
Step 2: Set java path in system environment variables path and click OK
Step 3: Download CloudSim 3.0.3 and commons math 3 jar file
https://github.com/Cloudslab/cloudsim/releases/tag/cloudsim-3.0.3
https://commons.apache.org/proper/commons-math/download_math.cgi
Step 6: To run CloudSim in eclipse, copy commons-math3-3.6.1 file from commons-math3-
3.6.1-bin folder & paste in jars file in cloudsim-3.0.3 folder
Step 4: Download Eclipse IDE and install
https://www.eclipse.org/downloads/packages/release/oxygen/3a/eclipse-ide-java-developers
Step 5: Open Eclipse IDE, create new java project & enter project name, select project location
Step 9: In Project Explorer click the project in examples & open any example scheduling
programs in org.cloudbus.cloudsim.examples
Step 10: Run the program and check the execution of CloudSim

PROGRAM:

package org.cloudbus.cloudsim.examples;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* A simple example showing how to create a datacenter with one host and run one
* cloudlet on it.
*/
public class CloudSimExample1 {

/** The cloudlet list. */


private static List<Cloudlet> cloudletList;
/** The vmlist. */
private static List<Vm> vmlist;
/**
* Creates main() to run this example.
*
* @param args the args
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample1...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
// Datacenters are the resource providers in CloudSim. We need at
// list one of them to run a CloudSim simulation
Datacenter datacenter0 = createDatacenter("Datacenter_0");
// Third step: Create Broker

DatacenterBroker broker = createBroker();


int brokerId = broker.getId();
// Fourth step: Create one virtual machine
vmlist = new ArrayList<Vm>();
// VM description
int vmid = 0;
int mips = 1000;
long size = 10000; // image size (MB)
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = 1; // number of cpus
String vmm = "Xen"; // VMM name
// create VM
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());
// add the VM to the vmList
vmlist.add(vm);
// submit vm list to the broker
broker.submitVmList(vmlist);
// Fifth step: Create one Cloudlet
cloudletList = new ArrayList<Cloudlet>();
// Cloudlet properties
int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, outputSize, utilizationModel,
utilizationModel, utilizationModel);
cloudlet.setUserId(brokerId);
cloudlet.setVmId(vmid);
// add the cloudlet to the list
cloudletList.add(cloudlet);
// submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);
// Sixth step: Starts the simulation
CloudSim.startSimulation();
CloudSim.stopSimulation();
//Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
Log.printLine("CloudSimExample1 finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
}
/**
* Creates the datacenter.
*
* @param name the name
*
* @return the datacenter
*/
private static Datacenter createDatacenter(String name) {
// Here are the steps needed to create a PowerDatacenter:

// 1. We need to create a list to store


// our machine
List<Host> hostList = new ArrayList<Host>();

// 2. A Machine contains one or more PEs or CPUs/Cores.


// In this example, it will have only one core.
List<Pe> peList = new ArrayList<Pe>();
int mips = 1000;

// 3. Create PEs and add these into a list.


peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS Rating

// 4. Create Host with its id and list of PEs and add them to the list
// of machines
int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;
hostList.add(

new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
); // This is our machine

// 5. Create a DatacenterCharacteristics object that stores the


// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).

String arch = "x86"; // system architecture


String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this
// resource
double costPerBw = 0.0; // the cost of using bw in this resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); // we are not adding SAN
// devices by now
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);

// 6. Finally, we need to create a PowerDatacenter object.


Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList),
storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
// We strongly encourage users to develop their own broker policies, to
// submit vms and cloudlets according
// to the specific rules of the simulated scenario
/**
* Creates the broker.
*
* @return the datacenter broker
*/
private static DatacenterBroker createBroker() {
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

/**
* Prints the Cloudlet objects.
*
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+ "Data center ID" + indent + "VM ID" + indent + "Time" + indent
+ "Start Time" + indent + "Finish Time");
DecimalFormat dft = new DecimalFormat("###.##");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
Log.printLine(indent + indent + cloudlet.getResourceId()
+ indent + indent + indent + cloudlet.getVmId()
+ indent + indent
+ dft.format(cloudlet.getActualCPUTime()) + indent
+ indent + dft.format(cloudlet.getExecStartTime())
+ indent + indent
+ dft.format(cloudlet.getFinishTime()));
}
}}}

OUTPUT:
RESULT:

Thus the simulation of cloud scenario using CloudSim and running a scheduling
algorithm that is not present in CloudSim was executed successfully.
Ex. No : 6
Find a procedure to transfer the files from one virtual
Date : machine to another virtual machine

AIM:
To find a procedure to transfer the files from one virtual machine to another virtual
machine

PROCEDURE:

Moving Files between Virtual Machines


You can move files between virtual machines in several ways:
• You can copy files using network utilities as you would between physical computers on
your network. To do this between two virtual machine:
o Both virtual machines must be configured to allow access to your network. Any
of the networking methods (host-only, bridged and NAT) are appropriate.
o With host-only networking, you copy files from the virtual machines to the host
and vice-versa, since host-only networking only allows the virtual machines see
your host computer.
o With bridged networking or NAT enabled, you can copy files across your
network between the virtual machines.
• You can create a shared drive, either a virtual disk or a raw partition, and mount the drive
in each of the virtual machines.

Three main options to share data between a virtual machine and a host PC:
• Drag and Drop (Copy and Paste)
• USB drive
• Shared Folder

Step 1: Select your virtual machine, right-click and select Settings.


Step 2: In the window that pops up, click on General and then click on the Advanced tab.
Step 3: You should now see the Shared Clipboard and Drag'n'Drop dropdown options.
Step 4: You can choose from Host to Guest, Guest to Host, and Bidirectional. There's also the
default option, Disabled. Select Bidirectional in both drop-down boxes to enable two-way file
sharing.
Create a Shared Folder in VirtualBox
Step 5: Launch VirtualBox and open Devices > Shared Folders > Shared Folders Settings
Step 6: In the Add Share window, give the share a name (keeping the same name in the guest
OS as the host OS is wise). Check Auto-mount and Make permanent, then OK
OUTPUT:
RESULT:
Thus the procedure to transfer the files from one virtual machine to another virtual
machine was executed successfully.
Ex. No : 7a
Install Hadoop single node cluster and run simple applications
Date : like wordcount

AIM:
To Install Hadoop single node cluster and run simple applications like wordcount.

PROCEDURE:

Step 1: Download & install Hadoop 2.8.0 & Java JDK 1.8.0
Setup Java and Hadoop
Step 2: Check either Java 1.8.0 is already installed on your system or not, use “Javac -
version” to check.
Step 3: If Java is not installed on your system then first install java under “C:\JAVA”
Step 4: Extract file Hadoop 2.8.0.tar.gz or Hadoop-2.8.0.zip and place under
“C:\Hadoop-2.8.0”.
Step 5: Set the path HADOOP_HOME Environment variable on windows 7/10

Configuration
Step 6: Edit file C:/Hadoop-2.8.0/etc/hadoop/core-site.xml, paste below xml paragraph
and save this file.
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
Step 7: Rename “mapred-site.xml.template” to “mapred-site.xml” and edit this file
C:/Hadoop-2.8.0/etc/hadoop/mapred-site.xml, paste below xml paragraph and save this
file.

<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
Step 8: Create folder “data” under “C:\Hadoop-2.8.0”
• Create folder “datanode” under “C:\Hadoop-2.8.0\data”
• Create folder “namenode” under “C:\Hadoop-2.8.0\data”

Step 9: Edit file C:\Hadoop-2.8.0/etc/hadoop/hdfs-site.xml, paste below xml paragraph


and save this file.
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/hadoop-2.8.0/data/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/hadoop-2.8.0/data/datanode</value>
</property>
</configuration>
Step 9: Edit file C:/Hadoop-2.8.0/etc/hadoop/yarn-site.xml, paste below xml paragraph
and save this file.
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
Step 10: Edit file C:/Hadoop-2.8.0/etc/hadoop/hadoop-env.cmd by closing the command
line “JAVA_HOME=%JAVA_HOME%” instead of set “JAVA_HOME=C:\Java” (On
C:\java this is path to file jdk.18.0)
Step 11: Hadoop Configuration
• Dowload file Hadoop Configuration.zip
• Delete file bin on C:\Hadoop-2.8.0\bin, replaced by file bin on file just download
(from Hadoop Configuration.zip).
• Open cmd and typing command “hdfs namenode –format” .
Step 12: Testing
• Open cmd and change directory to “C:\Hadoop-2.8.0\sbin” and type “start-
all.cmd” to start apache.
Make sure these apps are running
• Hadoop Namenode
• Hadoop datanode
• YARN Resourc Manager
• YARN Node Manager
Step 13: Open: http://localhost:8088
Step 14: Open: http://localhost:50070
OUTPUT:
RESULT:
Thus the procedure to Install Hadoop single node cluster and run simple applications like
wordcount was executed successfully.
Ex. No : 7b Run simple applications like Hadoop wordcount MapReduce
Program
Date :

AIM:
To run simple applications like Hadoop wordcount MapReduce Program.

PROCEDURE:

Step 1: Download MapReduceClient.jar


https://github.com/MuhammadBilalYar/HADOOP-INSTALLATION-ON-WINDOW-
10/blob/master/MapReduceClient.jar

Step 2: Download Input_file.txt


https://github.com/MuhammadBilalYar/HADOOP-INSTALLATION-ON-WINDOW-
10/blob/master/input_file.txt

Place both files in “C:/”

Step 3: Open cmd in Administrative mode and move to “C:/Hadoop-2.8.0/sbin” and start
cluster
Start-all.cmd
Step 4: Create an input directory in HDFS
hadoop fs -mkdir /input_dir

Step 5: Copy the input text file named input_file.txt in the input directory (input_dir) of
HDFS
hadoop fs -put C:/input_file.txt /input_dir
Step 8: Verify input_file.txt available in HDFS input directory (input_dir)
hadoop fs -ls /input_dir/
Step 9: Verify content of the copied file
hadoop dfs -cat /input_dir/input_file.txt

Step 10: Run MapReduceClient.jar and also provide input and out directories
hadoop jar C:/MapReduceClient.jar wordcount /input_dir /output_dir
Step 11: Verify content for generated output file
Some Other useful commands in hadoop:
To leave Safe mode
hadoop dfsadmin –safemode leave
To Delete file from HDFS directory
hadoop fs -rm -r /iutput_dir/input_file.txt
To Delete directory from HDFS directory
hadoop fs -rm -r /iutput_dir
OUTPUT:
RESULT:
Thus the procedure to run simple applications like hadoop wordcount program was
executed successfully.
Ex. No : 8
Creating and Executing Your First Container Using Docker
Date :

Aim:
To create and execute the container using Docker.

Prerequisites

1. Install Docker on your machine


For Ubuntu:
First, update your packages:

$ sudo apt update


Next, install docker with apt-get:

$ sudo apt install docker.io


Finally, verify that Docker is installed correctly:

$ sudo docker run hello-world


For MacOSX: you can follow this link. https://www.docker.com/products/docker-
desktop/

For Windows: you can follow this link. https://www.docker.com/products/docker-


desktop/

2. Create your project

In order to create your first Docker application, I invite you to create a folder on your
computer. It must contain the following two files:


A ‘main.py’ file (python file that will contain the code to be executed).

A ‘Dockerfile’ file (Docker file that will contain the necessary instructions to
create the environment).
Normally you should have this folder architecture:

.
├── Dockerfile
└── main.py
0 directories, 2 files

3. Edit the Python file

You can add the following code to the ‘main.py’ file:

#!/usr/bin/env python3

print("hello-world")
Nothing exceptional, but once you see “Docker is magic!” displayed in your terminal you
will know that your Docker is working.

4. Edit the Docker file

The first step to take when you create a Docker file is to access the DockerHub website.
This site contains many pre-designed images to save your time (for example: all images
for linux or code languages).

# A dockerfile must always start by importing the base image.


# We use the keyword 'FROM' to do that.
# In our example, we want import the python image.
# So we write 'python' for the image name and 'latest' for the version.
FROM python:latest

# In order to launch our python code, we must import it into our image.
# We use the keyword 'COPY' to do that.
# The first parameter 'main.py' is the name of the file on the host.
# The second parameter '/' is the path where to put the file on the image.
# Here we put the file at the image root folder.
COPY main.py /

# We need to define the command to launch when we are going to run the image.
# We use the keyword 'CMD' to do that.
# The following command will execute "python ./main.py".
CMD [ "python", "./main.py" ]

5. Create the Docker image

Once your code is ready and the Dockerfile is written, all you have to do is create your
image to contain your application.

$ docker build -t python-test .


The ’-t’ option allows you to define the name of your image. In our case we have chosen
’python-test’ but you can put what you want.

6. Run the Docker image

Once the image is created, your code is ready to be launched.

$ docker run python-test


You need to put the name of your image after ‘docker run’.

There you go, that’s it. You should normally see “hello-world” displayed in your
terminal.
Result:
Thus the creation and Execution of Container program using Docker executed
successfully.
Ex. No : 9
Run a Container From Docker Hub
Date :

Aim:
To run a container From Docker Hub.

Step-1: Verify Docker version and also login to Docker Hub

docker version
docker login
Step-2: Pull Image from Docker Hub

docker pull stacksimplify/dockerintro-springboot-helloworld-rest-api:1.0.0- RELEASE

Step-3: Run the downloaded Docker Image & Access the Application
• Copy the docker image name from Docker Hub
• docker run --name app1 -p 80:8080 -d stacksimplify/dockerintro-springboot-
helloworld-rest-api:1.0.0-RELEASE
• http://localhost/hello

Step-4: List Running Containers

docker ps
docker ps -a
docker ps -a –q

Step-5: Connect to Container Terminal

docker exec -it <container-name> /bin/sh

Step-6: Container Stop, Start

docker stop <container-name>


docker start <container-name>
AWS EKS - Elastic Kubernetes Service - Masterclass
Image

Step-7: Remove Container

docker stop <container-name>


docker rm <container-name>
Step-8: Remove Image

docker images
docker rmi <image-id>
Step-8: Remove Image

docker images
docker rmi <image-id

Result:

Thus the Container from Docker Hub executed Successfully.

You might also like