Docker OverView

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

INF4101-Big Data et NoSQL

2. Docker Overview

Dr Mouhim Sanaa
WHAT IS IN IT?
◾ MapReduce Introduction
◾ MapReduce Phases
◾ Word count exemples
◾ MapReduce java code
◾ how does Hadoop run MapReduce jobs
◾ Limitation of MapReduce V1
◾ YARN ARCHITECTURE
◾ YARN COMPONENTS
Docker Overview

• Docker is an open platform for developing, shipping, and running applications.


How to count the
• Docker enables you to separate your applications from your infrastructure so you can deliver
number ofsoftware
lines in
quickly. the file?

• Docker provides the ability to package and run an application in a loosely isolated environment called a
container.

• These containers package an application and its dependencies, ensuring consistent behavior
across different environments.
Docker Architecture

Docker client

• The Docker client (docker) is the primary way


that many Docker users interact with Docker.
When you use commands such as docker
run, the client sends these commands to
dockerd, which carries them out. The docker
command uses the Docker API. The Docker
client can communicate with more than one
daemon.
Docker Architecture

Docker Daemon

• The Docker daemon (dockerd) listens for


Docker API requests and manages Docker
objects such as images, containers,
networks, and volumes. A daemon can also
communicate with other daemons to manage
Docker services.
Docker Architecture

Docker Registry

• A Docker registry stores Docker images. Docker


Hub is a public registry that anyone can use, and
Docker looks for images on Docker Hub by
default. You can even run your own private
registry.
Docker Objects
When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other
objects. This section is a brief overview of some of those objects.

Images
Docker images are created from Dockerfiles, which contain instructions for building an image layer by layer.

Containers
Containers are instances of images, providing an isolated environment for running applications
Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

1. Create a file named Dockerfile (with no file extension) in a directory of your choice. This file
contains instructions for building the Docker image.

# Use an official Nginx base image


FROM nginx:alpine

# Copy a custom HTML file to the container


#COPY index.html /usr/share/nginx/html/

COPY index.html /usr/share/nginx/html/


Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

2. Create an index.html file in the same directory as the Dockerfile. This will be the content
displayed by the Nginx web server.

<!DOCTYPE html>
<html>
<head>
<title>Hello Docker!</title>
</head>
<body>
<h1>Hello, Docker!</h1>
<p>This is a simple Docker container running an Nginx web
server.</p>
</body>
</html>
Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

3. Open a terminal, navigate to the directory containing the Dockerfile and index.html, and
run the following command to build the Docker image

docker build -t my-nginx-image .

• The -t flag assigns a name (my-nginx-image) to the image


• The . at the end specifies the build context (current directory)
Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

4. Now that we have our Docker image, let’s run a container based on it. Run the
following command:

docker run -d -p 8080:80 my-nginx-image

• The -d flag runs the container in detached mode.


• The -p flag maps port 8080 on your host machine to port 80 on the container.
• my-nginx-image is the name of the image we created.
Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

5. Open a web browser and navigate to http://localhost:8080. You should see the
contents of the index.html file displayed by the Nginx web server running inside the
Docker container.

• The -d flag runs the container in detached mode.


• The -p flag maps port 8080 on your host machine to port 80 on the container.
• my-nginx-image is the name of the image we created.
Exemple
In this example, we’ll create a Docker image that contains a simple Nginx web server. We’ll then run a container
using that image.

To stop the container, run:

docker stop <container_id_or_name>

To remove the container, run:

docker rm <container_id_or_name>
Pushing and Pulling Docker Images to/from a Registry
• Docker images can be stored in public or private registries. Docker Hub is a popular public registry. Private
registries allow organizations to control image distribution and access.

• In this example, we’ll push the Nginx Docker image we created earlier to Docker Hub, a popular public Docker
registry.

1. Create an account on Docker Hub (https://hub.docker.com/) if you don’t have one.


2. Log in to Docker Hub using the command-line interface:
docker login

3. Tag the Docker image with your Docker Hub username and a repository name:

docker tag my-nginx-image:latest yourusername/my-nginx-image:latest

4. Push the tagged image to Docker Hub:

docker push yourusername/my-nginx-image:latest


Docker Compose

Docker Compose is a tool for defining and running multi-container applications.

• All the services must be deployed and run together


Front Back
DB
end end
• The services need to communicate

Servic
api ….
es

• Define and run multi services in 1 isolated environment


Docker Compose

Configuration

• You use a single YAML file to configure and maintain your application’s sevices

• With a single command, you create and start all the services from your configuration

version: "3.7"
services:
...
volumes:
...
networks:
...
Docker Compose

version: "3.7"
Configuration services:
...
volumes:
• services refer to the containers’ configuration. ...
networks:
services: ...
frontend:
image: my-vue-app
...
backend:
image: my-springboot-app
...
db:
image: postgres
...
Docker Compose

Configuration services:
my-service:
image: ubuntu:latest
• services refer to the containers’ configuration. ...

services:
services:
my-custom-app:
frontend:
build: /path/to/dockerfile/
image: my-vue-app
...
...
backend:
services:
image: my-springboot-app
my-custom-app:
...
build: https://github.com/my-company/my-
db:
project.git
image: postgres
image: my-project-image
...
...

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy