CS351 – A) Warm up on Docker Solved

$ 29.99
Category:

Description

Install and configure Docker/Container platform in an EC2 instance on AWS. Depending on your system, you might have to use sudo for all commands given below.
1. Install Docker Community Edition on your machine : https://docs.
docker.com/install/
On ubuntu it should be as easy as apt-get install docker docker.io -y
2. type docker in your terminal and check if its properly working.
3. Go to docker https://hub.docker.com. Search for the Python official image.
And pull the image having python version 3.8.
1 docker pull python:3.8-slim
2 #check the downloaded image
3 docker images
4. Fire up a container container.
1 #you can name it anything you want
2 docker run -dit –name=pyContainer python:3.8-slim 3 #your container should be listed here
4 docker container ls
5 #go inside your container, remember this
6 dockerexec-it pyContainer /bin/bash

If you have done it correctly, the something like the following should show up in your terminal root@02UwU3:/#

5. Inside the container go ahead check of the version python that you want is running correctly.
1 root@02UwU3:/# python -c”print(‘hello world’)”
2 root@02UwU3:/# python –version
3 #take note of the directory structure
4 root@02UwW3:/# ls
5 # exit the container like so
6 root@02UwW3:/#exit

6. The container is basically running linux, so think of it as being inside the terminal of your own laptop. You can run apt-get update and see for yourself. However, it is running in isolation, so its interaction with your machine is limited (can be changed). This container will have python3.8 installed by default, so that you don’t needlessly waste time setting up a another installation of python. This concept extends to any tool that you want to use!
7. Since the container is running isolated and running inside your terminal, the only way for you now is to create a new file inside the container and use commandline tools like vim, nano to make write any sort of script inside the container. This could be an annoyance.(if you are okay with it,then good for you.) Lets fix that. Since we cannot edit a launched container, we will stop and delete it and create a new container where we mount a folder of your local machine inside the container, so that any changes you make in that directory of your local machine shows up in your container. So, in your local terminal, run the following
1 # recall what you named your container
2 # if you dont, just ‘docker container ls’
3 docker container stop pyContainer
4 docker container rm pyContainer
5 #create a new folder or use an existing one
6 mkdir testfolder
7 #find out the path of your folder
8 pwd
9 # should print out something like /Users/userName/
10 docker run -dit –name=pyC

11 -v /Users/userName/testfolder:/myfolder
12 python:3.8-slim
13 dockerexec-it pyC /bin/bash
14 root@02UwU3:/# ls
15 # your mounted folder should up as ‘myfolder’. Any changes in this
16 # directory should show up in both your machine and this container

1. So just pull in your co-workers file, make the necessary changes and make sure it runs. And that it! You are done!
Here is the code that you need to finish implementing
fromtypingimportCallable, List importmath
#DO NOT MAKE UNNECESSARY CHANGES
classDistanceFuncs:
defcalc_distance( self, point_a: List[float], point_b: List[float], dist_func: Callable,/ )->float:
“”” Calculates distance between two points using the passed dist_func “””
returndist_func(point_a, point_b)

@staticmethod defeuclidean(point_a: List[float], point_b: List[float],/)->float:
“””
Calculates Euclidean Distance between two points Example:
>>> DistanceFuncs.euclidean([1,1],[1,1])
0.0
“””
returnmath.dist(point_a, point_b)
@staticmethod
defmanhattan_distance(point_a: List[float], point_b: List[float],/): “””Compute the manhattan_distance between two points””” raiseNotImplementedError()
@staticmethod
defjaccard_distance(point_a: List[float], point_b: List[float],/): “””Compute the jaccard_distance between two points””” raiseNotImplementedError()
defmain():
“””Demonstrate the usage of DistanceFuncs “””
pass
if name ==” main “:
main()
B) Your task is to extend the assignment 4. This time you are going to use containers instead of virtual machine images for deploying your applications to the cloud (the containers, however, will still run in virtual machines.)

Reviews

There are no reviews yet.

Be the first to review “CS351 – A) Warm up on Docker Solved”

Your email address will not be published. Required fields are marked *