一、在pom.xml中增加插件
<!-- Dockerfile maven plugin -->
二、編寫Dockerfile檔案
Dockerfile檔案需要跟pom檔案在同一級目錄下。
FROM
三、執行
#>mvn package dockerfile:build
四、需要注意的問題
1、需在maven/conf/下的setting.xml配置這個檔案在maven目錄下,可以 cd $M2_HOME/conf 進入。
在pluginGroups中增加一個com.spotify
<pluginGroups>
2.如果出現如下問題,需要配置國内鏡像: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
解決:
sudo vim /etc/docker/daemon.json
阿裡雲的鏡像{
"registry-mirrors":["https://6kx4zyno.mirror.aliyuncs.com"]
}
重新開機docker
三、本地做好的鏡像要想push到倉庫,必須先打成tag.docker tag 本地的image-name:版本号 xxx别名
docker push jessenqiang/xxx别名
問題:
如果出現:denied: requested access to the resource is denied
解決:
1 先登入 docker login
2 檢視tag是否有使用者名
四、問題
請注意,别忘記在<build>标簽中添加finalName