對(duì)于docker各個(gè)平臺(tái)的安裝和docker的好處就不說了斤儿。
了解docker最快的辦法當(dāng)然就是用它了??
docker架構(gòu)組織關(guān)系
先簡(jiǎn)單了解下docker的一個(gè)架構(gòu)
-
docker daemon
我們也稱之為docker的守護(hù)進(jìn)程呛哟,叫做docker的server端 -
docker CLI
提供給我們一個(gè)統(tǒng)一的操作界面,實(shí)現(xiàn)容器和鏡像的管理凳谦,也叫做docker的client端 - server端和client是通過REST API來進(jìn)行通信的,所以說server端和client是可以分開部署
- 我們不能直接與server進(jìn)行交互媒楼,但是可以通過容器這個(gè)橋梁來進(jìn)行交互
-
Image
(鏡像): 一個(gè)只讀的鏡像模板掀宋。可以自己創(chuàng)建一個(gè)鏡像也可以從網(wǎng)站上下載鏡像供自己使用盔性。鏡像包含了一個(gè)RFS(Root File System) -
Container
(容器):由client通過鏡像創(chuàng)建的實(shí)例霞丧,用戶在容器中運(yùn)行應(yīng)用,每個(gè)應(yīng)用運(yùn)行在隔離的容器中冕香,享有獨(dú)自的權(quán)限蛹尝、用戶、網(wǎng)絡(luò)悉尾。確保不會(huì)相互干擾突那。 -
Data Volumes
(數(shù)據(jù)卷):Volume可以將容器以及容器產(chǎn)生的數(shù)據(jù)分離開來,這樣构眯,當(dāng)你使用docker rm my_container
刪除容器時(shí)愕难,不會(huì)影響相關(guān)的數(shù)據(jù)。
docker 相關(guān)命令
- docker version
docker是GO語言開發(fā)的惫霸,所以會(huì)包含GO的版本
? ~ docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:13:02 2018
OS/Arch: darwin/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:22:38 2018
OS/Arch: linux/amd64
Experimental: true
- docker info
~ docker info
Containers: 4 // docker 創(chuàng)建的容器
Running: 0 // 在運(yùn)行的容器
Paused: 0 // 暫停的容器
Stopped: 4 // 停止的容器
Images: 5 // 鏡像的數(shù)量
Server Version: 18.03.1-ce // 服務(wù)端版號(hào)
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay // 網(wǎng)絡(luò)類型
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: WTAC:2JEJ:57L7:SWDY:XB7L:N5PK:GZ5Z:OXZS:FDAY:4WX5:ABAV:7DGW
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 21
Goroutines: 39
System Time: 2018-05-04T09:49:53.103863977Z
EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://oyukeh0j.mirror.aliyuncs.com/
Live Restore Enabled: false
- docker --help
Usage: docker COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/Users/FDT/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/Users/FDT/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/Users/FDT/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/Users/FDT/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
checkpoint Manage checkpoints
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes