{"Client":{"Platform":{"Name":""},"CloudIntegration":"v1.0.23","Version":"20.10.14","ApiVersion":"1.41","DefaultAPIVersion":"1.41","GitCommit":"a224086","GoVersion":"go1.16.15","Os":"darwin","Arch":"amd64","BuildTime":"Thu Mar 24 01:49:20 2022","Context":"default","Experimental":true},"Server":{"Platform":{"Name":"Docker Desktop 4.7.1 (77678)"},"Components":[{"Name":"Engine","Version":"20.10.14","Details":{"ApiVersion":"1.41","Arch":"amd64","BuildTime":"Thu Mar 24 01:46:14 2022","Experimental":"false","GitCommit":"87a90dc","GoVersion":"go1.16.15","KernelVersion":"5.10.104-linuxkit","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"1.5.11","Details":{"GitCommit":"3df54a852345ae127d1fa3092b95168e4a88e2f8"}},{"Name":"runc","Version":"1.0.3","Details":{"GitCommit":"v1.0.3-0-gf46b6ba"}},{"Name":"docker-init","Version":"0.19.0","Details":{"GitCommit":"de40ad0"}}],"Version":"20.10.14","ApiVersion":"1.41","MinAPIVersion":"1.12","GitCommit":"87a90dc","GoVersion":"go1.16.15","Os":"linux","Arch":"amd64","KernelVersion":"5.10.104-linuxkit","BuildTime":"2022-03-24T01:46:14.000000000+00:00"}}
docker version --format '{{.Server.Version}}'
1
20.10.14
docker run
例子
docker run --name test -it debian
1
2
3
4
5
6
7
8
9
10
11
12
$ docker run --name test -it debian
Unable to find image 'debian:latest' locally
latest: Pulling from library/debian
6aefca2dc61d: Already exists
Digest: sha256:6846593d7d8613e5dcc68c8f7d8b8e3179c7f3397b84a47c5b2ce989ef1075a0
Status: Downloaded newer image for debian:latest
exit13echo$?13$ docker ps -a | grep testa30b8390fce8 debian "bash"2 minutes ago Exited (13) About a minute ago
$ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu
root@be74d2cdbc61:/Users/joker#
root@be74d2cdbc61:/Users/joker# ls
1.mpeg Documents Library Music Postman blog java_error_in_goland_52033.log software_pkg
Desktop Downloads Movies Pictures Public code software
很明显,进入容器后,访问的是是宿主机的家目录。
1
$ docker run --read-only -v /icanwrite busybox touch /icanwrite/here
–mount
1
$ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
docker-compose
Compose is a tool for defining and running multi-container Docker applications
$ docker-compose -h
Define and run multi-container applications with Docker.
Usage:
docker-compose [-f <arg>...][--profile <name>...][options][--][COMMAND][ARGS...] docker-compose -h|--help
Options:
-f, --file FILE Specify an alternate compose file
(default: docker-compose.yml) -p, --project-name NAME Specify an alternate project name
(default: directory name) --profile NAME Specify a profile to enable -c, --context NAME Specify a context name
--verbose Show more output
--log-level LEVEL Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) --ansi (never|always|auto) Control when to print ANSI control characters
--no-ansi Do not print ANSI control characters (DEPRECATED) -v, --version Print version and exit -H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by --tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the
name specified in the client certificate
--project-directory PATH Specify an alternate working directory
(default: the path of the Compose file) --compatibility If set, Compose will attempt to convert keys
in v3 files to their non-Swarm equivalent (DEPRECATED) --env-file PATH Specify an alternate environment file
Commands:
build Build or rebuild services
config Validate and view the Compose file
create Create services
down Stop and remove resources
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show version information and quit
version:'3.7'# Settings and configurations that are common for all containersx-minio-common:&minio-commonimage:quay.io/minio/minio:RELEASE.2022-06-03T01-40-53Zcommand:server --console-address ":9001" http://minio{1...4}/data{1...2}expose:- "9000"- "9001"# environment:# MINIO_ROOT_USER: minioadmin# MINIO_ROOT_PASSWORD: minioadminhealthcheck:test:["CMD","curl","-f","http://localhost:9000/minio/health/live"]interval:30stimeout:20sretries:3# starts 4 docker containers running minio server instances.# using nginx reverse proxy, load balancing, you can access# it through port 9000.services:minio1:<<:*minio-commonhostname:minio1volumes:- data1-1:/data1- data1-2:/data2minio2:<<:*minio-commonhostname:minio2volumes:- data2-1:/data1- data2-2:/data2minio3:<<:*minio-commonhostname:minio3volumes:- data3-1:/data1- data3-2:/data2minio4:<<:*minio-commonhostname:minio4volumes:- data4-1:/data1- data4-2:/data2nginx:image:nginx:1.19.2-alpinehostname:nginxvolumes:- ./nginx.conf:/etc/nginx/nginx.conf:roports:- "9000:9000"- "9001:9001"depends_on:- minio1- minio2- minio3- minio4## By default this config uses default local driver,## For custom volumes replace with volume driver configuration.volumes:data1-1:data1-2:data2-1:data2-2:data3-1:data3-2:data4-1:data4-2: