-
Notifications
You must be signed in to change notification settings - Fork 2
Docker基础笔记
xiaoke_1256 edited this page Aug 11, 2024
·
11 revisions
Home >> Docker相关笔记 >> Docker基础笔记
- 安装指定版本:
请参考这里。
- 安装完毕后,修改docker配置:
在/etc/docker/目录下创建文件daemon.json,内容如下:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
"insecure-registries": ["repo.orders.com:5000"]
}
如果 https://docker.mirrors.ustc.edu.cn/ 不好用,可以用以下地址:https://docker.awsl9527.cn/ , https://dockerhub.icu/ ,https://hub.uuuadc.top/ ,https://docker.anyhub.us.kg/
- 修改docker.service文件
# sudo vim /usr/lib/systemd/system/docker.service
然后在文件中找到"ExecStart"那一行,在行末加上-H tcp://0.0.0.0:2375
。然后重启docker daemon和docker ,如下命令:
# sudo systemctl daemon-reload && sudo systemctl restart docker
- docker仓库,开始即启动的命令:
sudo docker run -d -v /registry:/var/lib/registry -p 5000:5000 --restart=always /
--name registry registry:2
如果仓库需要配置密码请看这里。
- 从Dockerfile文件构建镜像:
sudo docker build -t repo.orders.com:5000/orders/base_web:1.0.0 /
-t repo.orders.com:5000/orders/base_web:latest .
sudo docker build -t repo.orders.com:5000/orders/product:1.1.2 /
-t repo.orders.com:5000/orders/product:latest .
sudo docker build -t repo.orders.com:5000/3rdpay/3rdpay:1.1.3 /
-t repo.orders.com:5000/3rdpay/3rdpay:latest .
- 将镜像上传至docker库中:
sudo docker push repo.orders.com:5000/orders/base_web:latest
- 以Docker容器方式运行一个war包:
sudo docker run --env EXT_JAVA_OPTS="-Dserver.port=8084" /
-d -p 8084:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always /
repo.orders.com:5000/orders/product
sudo docker run --env EXT_JAVA_OPTS="-Dserver.port=8082" /
-d -p 8082:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always repo.orders.com:5000/3rdpay/3rdpay
sudo docker run --env EXT_JAVA_OPTS="-Dserver.port=8081" /
-d -p 8081:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always repo.orders.com:5000/orders/orders
sudo docker run --env EXT_JAVA_OPTS="-Dserver.port=8080" /
-d -p 8080:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always repo.orders.com:5000/orders/product-search
sudo docker run --env EXT_JAVA_OPTS="-Dserver.port=8085" /
-d -p 8085:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always repo.orders.com:5000/orders/orders-task
sudo docker run --env EXT_JAVA_OPTS="-Dspring.profiles.active=peer2" /
-d -p 8762:8080 /
--add-host db1.orders.com:192.168.xx.1 /
--add-host redis:192.168.xx.100 /
--add-host p.es:192.168.xx.100 /
--add-host zk1:192.168.xx.100 /
--add-host peer1:192.168.xx.121 /
--add-host peer2:192.168.xx.122 /
--restart=always repo.orders.com:5000/orders/discovery
- 查看registry上有哪些版本:
http://repo.orders.com:5000/v2/orders/orders/tags/list
Hi