# Docker
# Concepts
# 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
# How it 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.
# Workflow
# Use cases
# 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>