我有码头文件
FROM java:8
# Install maven
RUN apt-get update
RUN apt-get install -y maven
WORKDIR /code/
# Prepare by downloading dependencies
#ADD pom.xml /mmt/CouchBaseClient/CB-RestAPI/CacheService/pom.xml
#RUN ["mvn", "dependency:resolve"]
#RUN ["mvn", "verify"]
ADD cacheService-0.0.1-SNAPSHOT.jar /code/cacheService-0.0.1-SNAPSHOT.jar
ADD couchclient-0.0.1-SNAPSHOT.jar /code/couchclient-0.0.1-SNAPSHOT.jar
EXPOSE 4567
CMD ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-jar", "couchclient-0.0.1-SNAPSHOT.jar server cacheService.yml" ]
当我构建这个文件时,我得到以下输出
Sending build context to Docker daemon 35.46 MB
Step 1 : FROM java:8
---> 736600fd4ae5
Step 2 : RUN apt-get update
---> Using cache
---> a3466698c29d
Step 3 : RUN apt-get install -y maven
---> Using cache
---> d0fb8e77f89a
Step 4 : WORKDIR /code/
---> Using cache
---> 197735d2da02
Step 5 : ADD cacheService-0.0.1-SNAPSHOT.jar /code/cacheService-0.0.1-SNAPSHOT.jar
---> 9ba30f5a2144
Removing intermediate container bd3c072ebbc6
Step 6 : ADD couchclient-0.0.1-SNAPSHOT.jar /code/couchclient-0.0.1-SNAPSHOT.jar
---> ef59315ed7fe
Removing intermediate container 0da1a69bdb51
Step 7 : EXPOSE 4567
---> Running in a2b32799dd6c
---> 3fb2b534d7c5
Removing intermediate container a2b32799dd6c
Step 8 : CMD /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar couchclient-0.0.1-SNAPSHOT.jar server cacheService.yml
---> Running in efb44e2bcdb3
---> 56637dfacc0d
Removing intermediate container efb44e2bcdb3
Successfully built 56637dfacc0d
但是没有创建名为 code 的目录,因此即使没有编译错误,也没有添加文件
@VonC 建议的使用方法
ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-jar", "couchclient-0.0.1-SNAPSHOT.jar" ]
然后使用此命令运行映像
docker run <image> -d <arguments>