檢視Docker版本
docker --version
//輸出
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 634eae
Built: Wed Nov 13 07:22:34 2019
OS/Arch: darwin/amd64
Experimental: false
複製程式碼
登陸Docker倉庫
song@song:~|⇒ docker login docker.io
Username (song):
Password:
login success!
複製程式碼
映象相關命令
docker search elasticsearch
//輸出
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
elasticsearch Elasticsearch is a powerful open source sear… 4267 [OK]
nshou/elasticsearch-kibana Elasticsearch-7.5.1 Kibana-7.5.1 118 [OK]
itzg/elasticsearch Provides an easily configurable Elasticsearc… 70 [OK]
mobz/elasticsearch-head elasticsearch-head front-end and standalone … 58
elastichq/elasticsearch-hq Official Docker image for ElasticHQ: Elastic… 48 [OK]
elastic/elasticsearch The Elasticsearch Docker image maintained by… 29
bitnami/elasticsearch Bitnami Docker Image for Elasticsearch 28 [OK]
taskrabbit/elasticsearch-dump Import and export tools for elasticsearch 20 [OK]
lmenezes/elasticsearch-kopf elasticsearch kopf 18 [OK]
barnybug/elasticsearch Latest Elasticsearch 1.7.2 and previous rele… 17 [OK]
複製程式碼
docker pull elasticsearch:latest
複製程式碼
docker tag nodejs:latest nodejs:v1
docker tag nodejs:v1 docker.io/xxx/nodejs:v1
複製程式碼
docker build -t test:latest -f Dockerfile .
複製程式碼
docker push docker.io/xxx/nodejs:v1
複製程式碼
docker rmi nodejs:v1
複製程式碼
docker rmi $(docker images | grep "none" | awk '{print $3}')
複製程式碼
docker inspect nodejs:v1
複製程式碼
容器相關命令
docker run -d --name elasticsearch --restart=always -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" elasticsearch:6.7.1
複製程式碼
docker stop elasticsearch
複製程式碼
docker rm elasticsearch
複製程式碼
docker restart elasticsearch
複製程式碼
docker exec elasticsearch -it /bin/bash
複製程式碼
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' elasticsearch
複製程式碼
網路相關命令
docker network ls
//輸出
NETWORK ID NAME DRIVER SCOPE
12b42610291a bridge bridge local
b37807026f86 host host local
d61f9f7674a3 none null local
複製程式碼
docker network inspect host
或
docker network inspect host none
//輸出
[
{
"Name": "host",
"Id": "xxxxxxxxxx",
"Created": "2020-02-14T03:19:05.612424113Z",
"Scope": "local",
"Driver": "host",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": []
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]
複製程式碼
docker network connect host [容器名稱]
複製程式碼
docker network create bridge2
複製程式碼
docker network disconnect host [容器名稱]
複製程式碼
docker network rm host
複製程式碼
docker network prune
複製程式碼