私は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''。これでも動作しません。私は大丈夫のためにプロキシが必要です – cppcoder
ああ、私は答えを編集させてください。 mavenは特別な設定が必要です –
@cppcoder、今すぐ編集を確認してください –