This post is intended to be used in my master course CC-MEI-2021 as a Hands-on 2
What is a Docker?
Wikipedia defines Docker as
an open-source project that automates the deployment of software applications inside containers by providing an additional layer of abstraction and automation of OS-level virtualization on Linux.
Docker is the worlds leading software container platform. Developers use Docker to eliminate works on my local machine problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely, and with confidence for both Linux and Windows Server apps. A container image is a lightweight, standalone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows-based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example, differences between development and staging environments, and help reduce conflicts between teams running different software on the same infrastructure. In this course, we will use Docker in order to isolate all the frameworks and programs and avoid configuration problems.
The key benefit of Docker in this course is that it allows us to package an application with all of its dependencies into a standardized unit for software development independent of the hosting Operating System.
Task 1.1: Install Docker for your platform
- Windows 10 Pro/Enterprise, macOS, Linux: Link to Docker Store.
- Other Windows versions: Link to Docker Toolbox.
Task 1.2: Download the Docker image. Open a terminal (Mac/Linux), Open cmd or powershell (Windows 10 Pro) or Open the Docker CLI (Other windows versions) and then run:
#Download the docker image docker pull jorditorresbcn/dl
MacOS and Windows users should have the docker program open in order to run docker commands. This docker image is based on Ubuntu 16.04 with the following software stack: Python3.5, Keras, TensorFlow, nano, htop, iPython, Jupyter, matplotlib, NLTK, and git.
Task 1.3: Run the docker image for the first time. Open a terminal on Linux/Mac, PowerShell on Windows 10, or the Docker CLI on other Windows versions and then run:
#Create a container docker run -it -p 8888:8888 --name test jorditorresbcn/dl:latest
If you close the container and you need to re-open it, run:
docker start -i test
With docker kill, you can kill one or more running containers.
We will use Python. Python is a widely-used programming language (source code is now available under the GNU General Public License GPL) started by Guido van Rossum that supports multiple programming paradigms. Although it is an interpreted language rather than compiled language and therefore might take up more CPU time (important detail in our Computer Architecture department), Python has a gentle learning curve. Python is readable, writeable, and endlessly powerful. Its simplicity lets you become productive quickly. Python is the programming language of choice for our labs. Only Python basics are required in order to follow these labs. If you have no prior knowledge of Python, to help you learn the required background knowledge by yourself, you can follow this Python QuickStart.
Task 1.4: Run the Jupyter Notebook server
After your installation process is finished you can start iPython notebook by writing
jupyter notebook --ip=0.0.0.0 --allow-root on your terminal:
#Inside the container #Ignore the error-> No web browser found: could not locate runnable browser. jupyter notebook --ip=0.0.0.0 --allow-root
This will launch a new browser window (or a new tab) showing the Notebook Dashboard on localhost to the URL of your Notebooks, by default http://127.0.0.1:8888. On your computer, open your browser and go to http://localhost:8888, the password is dl.
If you are on windows and you are experiencing connectivity issues, please check THIS.
Task 1.5: On your browser, create a new notebook.
You can create a new iPython notebook by simply clicking on the new button at the top. The interface shows In[*] for inputs and Out[*] for output. You can execute a code by pressing “Shift + Enter” or “ALT + Enter”, if you want to insert an additional row after.
Run the following code:
%matplotlib inline from matplotlib import pyplot as plt import numpy as np
Create 50 random points:
N = 50 x = np.random.rand(N) y = np.random.rand(N)
Plot the points:
plt.scatter(x, y) plt.show()