我想克隆一個Git項目,做mvn package
泊塢窗內。但是maven無法連接到網絡來下載依賴關係。這是Dockerfile
:的Maven無法連接到網絡內的碼頭工人
FROM java:8
FROM maven
ADD id_rsa /root/.ssh/id_rsa
ADD known_hosts /root/.ssh/known_hosts
RUN git clone [email protected]:project/myapp.git
WORKDIR myapp
RUN mvn package
這是Maven構建命令:
sudo docker build --build-arg http_proxy=http://proxy.in.my.com:80
--build-arg https_proxy=http://proxy.in.my.com:80
--build-arg ftp_proxy=http://proxy.in.my.com:80
--build-arg no_proxy=localhost,127.0.0.1,.us.my.com,.my.com
-t myapp .
期間mvn package
我收到以下錯誤:
Downloading: https://repo.maven.apache.org/maven2/org/jacoco/jacoco-maven-plugin/0.7.6.201602180812/jacoco-maven-plugin-0.7.6.201602180812.pom
[ERROR] Plugin org.jacoco:jacoco-maven-plugin:0.7.6.201602180812 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.jacoco:jacoco-maven-plugin:jar:0.7.6.201602180812: Could not transfer artifact org.jacoco:jacoco-maven-plugin:pom:0.7.6.201602180812 from/to central (https://repo.maven.apache.org/maven2): Network is unreachable (connect failed) -> [Help 1]
我曾嘗試直接在Dockerfile這樣給代理:'ENV HTTP_PROXY「proxy''。即使這不起作用。我需要代理maven – cppcoder
噢好吧,讓我編輯答案。 maven需要特殊設置 –
@cppcoder,現在檢查編輯 –