# Docker

⚡️ Tags: 📍Tools 📍Overview 📍Docker

# Concepts

Containerization

Docker Concepts

# Main components

Docker Main components

  • Docker Hub: store Docker Image
  • Docker Engine: create Docker Image & run Docker Container
  • Docker Machine: create Docker Engine on Server
  • Docker Compose: run application by defining Docker Container configuration in file
  • Docker Image: (immutable)
  • Docker Container: …

# Benifits

Docker Benifits

# How it works

How docker works

Docker's architecture comprises three main components:

🔹 Docker Client This is the interface through which users interact. It communicates with the Docker daemon.

🔹 Docker Host Here, the Docker daemon listens for Docker API requests and manages various Docker objects, including images, containers, networks, and volumes.

🔹 Docker Registry This is where Docker images are stored. Docker Hub, for instance, is a widely-used public registry.

Read more (opens new window)

# Workflow

Docker Workflow 2

Docker Workflow

# Use cases

Docker use cases

# Commands

Docker commands

# Image

# Container

# Save as Image

Container must be stoped before committing.

docker commit <container-name> <new-image-name:tag>

# Run

# Expose Port

docker run -d -p 5801:5800 --name vnc1 myvnc 

multi ports

docker run -d -p 5801:5801 -p 5802:5802 .....

# Volume

docker run -it -v <path-host>:<container-path> <ID or NAME>
# E.g:
docker run -it -v /Users/nguyenkhank/Desktop/jav:/home/dulieu ubuntu

Use the same data:

docker run -it --name C2 --volumes-from C1 ubuntu:latest

# With Volume

docker run -it --name <container-name> --mount source=<volume-name>,target=<container-path> <image-name:tag>
# E.g:
docker run -it --name C1 --mount source=D1,target=/home/dulieu ubuntu:16.0.4

Case volume mounted with device

docker run -it --name <container-name> --mount source=<volume-name>,target=<container-path> <image-name:tag>
# E.g:
docker run -it --name C1 -v DISK1:/home/dulieu ubuntu:16.0.4

# Exit

# Exit and Stop Docker Container

  • Ctrl+C to send the SIGINT signal and stop the process. Next, press Ctrl+D to exit and stop the container.
  • Alternatively, type exit

# Exit Docker Container without Stopping It

  • press Ctrl+P followed by Ctrl+Q. This operation detaches the container and allows you to return to your system's shell.

# Volume

# Network

Detail (opens new window) Detail (opens new window)

# Other

Info

docker info
docker -v

Help

docker image --help

Search

docker search <keyword>

# Simple build

# Docker vs K8S

Docker vs K8S