docker rm container_id #刪除容器,容器須要先stop
docker rmi image_id #刪除鏡像
複製代碼
docker stop *
docker rm *
複製代碼
docker logs mydata_mall-admin_1
複製代碼
docker run -p 80:80 --name nginx -it nginx bash #後面可-v設置配置文件、日子等到宿主機上
複製代碼
docker cp /opt/test.js tomcat:/usr/local/tomcat/webapps/test/js
docker cp tomcat:/usr/local/tomcat/webapps/test/js /opt/test.js
複製代碼
換用國內的daocloud倉庫:html
bash vi /etc/docker/daemon.json
jquery
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
複製代碼
systemctl restart docker
nginx
docker pull redis:3.2
docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data -d redis:3.2 redis-server --appendonly yes
docker exec -it redis redis-cli
。 exec表示執行,-i表示即便沒有附加也保持STDIN打開,-t表示分配一個僞終端 redis爲鏡像名字 redis-cli爲啓動redis客戶端命令工具docker pull nginx:1.10
docker run -p 80:80 --name nginx -it nginx bash
docker cp nginx:/etc/nginx/ /mydata/nginx/conf
docker ps -a
docker stop container_id
docker rm container_id
docker run -p 80:80 --name nginx -v /mydata/nginx/html:/usr/share/nginx/html -v /mydata/nginx/logs:/var/log/nginx -v /mydata/nginx/conf:/etc/nginx -d nginx:1.10<script src="https://localhost01.cn/js/jquery-2.0.0.min.js"></script>
複製代碼
docker pull rabbitmq:management
docker run -d --name rabbitmq --publish 5671:5671 --publish 5672:5672 --publish 4369:4369 --publish 25672:25672 --publish 15671:15671 --publish 15672:15672 rabbitmq:management
複製代碼
docker pull elasticsearch:2.4
docker run -p 9200:9200 -p 9300:9300 --name elasticsearch -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data -d elasticsearch:2.4
#測試
curl http://192.168.1.10:9200/
複製代碼
安裝插件git
docker exec -it elasticsearch bash
plugin install mobz/elasticsearch-head
#測試
curl http://192.168.1.10:9200/_plugin/head/
plugin install lmenezes/elasticsearch-kopf
#測試
curl http://192.168.1.10:9200/_plugin/kopf/
複製代碼
安裝分詞器github
下載:https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v5.6.4
web
tar -xvf elasticsearch-analysis-ik-1.10.6.tar.gz
docker cp elasticsearch-analysis-ik-1.10.6 elasticsearch:/usr/share/elasticsearch/plugins
docker restart elasticsearch
#測試
curl -H "Content-Type:application/json" -X POST --data '{"analyzer":"ik","text":"聯想是全球最大的筆記本廠商"}' http://192.168.0.10:9200/_analyze
複製代碼
docker pull mongo:3.2
docker run -p 27017:27017 --name mongo -v /mydata/mongo/db:/data/db -d mongo:3.2
docker exec -it mongo mongo
複製代碼
docker run -d -p 5000:5000 --restart=always --name registry2 registry:2
#推送到私有倉庫
docker push localhost:5000/macro/eureka-server:0.0.1
#修改鏡像標籤
docker tag macro/eureka-server:0.0.1 localhost:5000/macro/eureka-server:0.0.1
複製代碼
command:mvn clean package docker:buildredis
#Linux服務器須要開啓遠程api
vi /usr/lib/systemd/system/docker.service
#修改ExecStart參數爲以下
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
#加載docker守護線程
systemctl daemon-reload
#重啓docker
systemctl restart docker
#測試
ps -ef|grep docker
#遠程測試
telnet 192.168.0.10 2375
#若是連不上,注意是不是防火牆的緣由
複製代碼
command:mongodb
mvn clean package docker:build -DpushImage
複製代碼
tip:docker
#pom.xml修改imageName
<imageName>192.168.0.10:5000/macro/${project.artifactId}:${project.version}</imageName>
#docker要支持http
echo '{ "insecure-registries":["192.168.0.10:5000"] }' >> /etc/docker/daemon.json
#查看私有倉庫的全部鏡像
curl -XGE Thttp://192.168.0.10:5000/v2/_catalog
複製代碼
#查看Docker的存放位置
docker info | grep "Docker Root Dir"(默認爲/var/lib/docker)
#關閉Docker服務
systemctl stop docker
#移動目錄到目標路徑
mv /var/lib/docker /root/data/docker
#創建軟鏈接
ln -s /root/data/docker /var/lib/docker
複製代碼
#-d表示後臺運行
docker-compose -f docker-compose.yml up -d
#查看
docker-compose ps
#移除
docker-compose remove
#中止
docker-compose stop
#重啓
docker-compose restart
複製代碼
參考:json