Docker Introduction and its Usage in Machine Learning
yogendra18
11 views
31 slides
Jul 23, 2024
Slide 1 of 31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
About This Presentation
Docker Introduction and its Usage in Machine Learning.
Size: 1.21 MB
Language: en
Added: Jul 23, 2024
Slides: 31 pages
Slide Content
Docker: Introduction and its Usage in Machine Learning By: Yogendra Singh IIT Indore
What is Docker?
Lightweight, open, secure platform Simplify building, shipping, running app s Runs natively on Linux or Windows Server Runs on Windows or Mac Development machines (with a virtual machine) Relies on "images" and "containers" Docker is a software platform that allows you to build, test, and deploy applications quickly, packaging software into standardized units called containers .
Get Docker Installation instructions available in https://docs.docker.com/get-docker/ For Linux, Windows and Mac OS
What are containers? Source: docs.docker.com Container ≠ VM Isolated Share OS and sometimes bins/libs
Standardized packaging for software and dependencies Isolate apps from each other Share the same OS kernel Works for all major Linux distributions Containers native to Windows Server 2016 ….. What is a container?
Docker Image Example: Ubuntu with Node.js and Application Code Docker Container Created by using an image. Runs your application. The Role of Images and Containers
Some Docker vocabulary Docker Image The basis of a Docker container. Represents a full application Docker Container The standard unit in which the application service resides and executes Docker Engine Creates, ships and runs Docker containers deployable on a physical or virtual, host locally, in a datacenter or cloud service provider Registry Service (Docker Hub ( Public ) or Docker Trusted Registry ( Private ) Cloud or server based storage and distribution service for your images
14 Dockerfile – Linux Example Instructions on how to build a Docker image Looks very similar to “native” commands Important to optimize your Dockerfile
Section 2: Anatomy of a Docker Container Docker Volumes Volume Use Cases
Let’s Go Back to Our Dockerfile 17
Each Dockerfile Command Creates a Layer Kernel FROM 18 RUN WORKDIR COPY EXPOSE …
Docker Image Pull: Pulls Layers 19
Docker Volumes 20 Volumes mount a directory on the host into the container at a specific location Can be used to share (and persist) data between containers Directory persists after the container is deleted Unless you explicitly delete it Can be created in a Dockerfile or via CLI
Why Use Volumes 21 Mount local source code into a running container docker container run -v $(pwd):/usr/src/app/ myapp Improve performance − As directory structures get complicated traversing the tree can slow system performance Data persistence
Docker Bridge Networking and Port Mapping Docker host 1 Bridge Cntnr1 10.0.0.8 L2/L3 physical network :80 :8080 172.14.3.55 $ docker container run -p 8080:80 ... Host port 24 Container port
Section 4: Docker Compose
Docker Compose: Multi Container Applications 49 Build and run one container at a time Manually connect containers together Must be careful with dependencies and start up order Define multi container app in compose.yml file Single command to deploy entire app Handles container dependencies Works with Docker Swarm, Networking, Volumes, Universal Control Plane
version: '2' # specify docker-compose version # Define the services/containers to be run services: angular: # name of the first service build: client # specify the directory of the Dockerfile ports: - "4200:4200" # specify port forewarding express: #name of the second service build: api # specify the directory of the Dockerfile ports: - "3977:3977" #specify ports forewarding database: # name of the third service image: mongo # specify image to build container from ports: - "27017:27017" # specify port forewarding Docker Compose: Multi Container Applications
Docker images Docker Hub Dockerfile
Docker Hub
Dockerfile It is possible to build your own images reading instructions from a Dockerfile FROM centos:7 RUN yum install -y python- devel python- virtualenv RUN virtualenv /opt/ indico / venv RUN pip install indico COPY entrypoint.sh /opt/indico/entrypoint.sh EXPOSE 8000 ENTRYPOINT /opt/indico/entrypoint.sh
docker -compose Allows to run multi-container Docker applications reading instructions from a docker-compose.yml file version: "2" services: my-application: build: ./ ports: - "8000:8000" environment: - CONFIG_FILE db : image: postgres redis : image: redis command: redis -server --save "" -- appendonly no ports: - "6379"