尝试运行docker容器时出现以下错误:
Error: Unable to access jarfile
我的Dockerfile是这样的:
FROM ubuntu:16.04
# Install Updates
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y software-properties-common && \
apt-add-repository -y ppa:openjdk-r/ppa && \
apt-get update -y && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/*
# Install Packages
RUN apt-get -qq update -y && \
apt-get -q install -y \
wget \
openssh-server \
openjdk-8-jdk \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/*
# Add the config files
ADD /apps/ /home/smartling/
# Adding the jar application
ADD /apps/flagship/repo-connector-1.5.4/repo-connector-1.5.4.jar /home/smartling/flagship/repo-connector-1.5.4/
# Making sure the files are there
RUN ls -la /home/smartling/flagship/repo-connector-1.5.4/
# Start the jar file when container launches
CMD ["java","-jar","/home/smartling/flagship/repo-connector-1.5.4/repo-connector-1.5.4.jar -start&"]
然后我建立
docker build -t smartlingflagship .
一切都恢复成功
我运行容器
docker run --rm --name smartlingconn smartlingflagship
它返回时出现以下错误:
Error: Unable to access jarfile /home/smartling/flagship/repo-connector-1.5.4/repo-connector-1.5.4.jar -start&
我错过了什么吗?
答案 0 :(得分:1)
我可以通过将其添加到底部ENTRYPOINT ["java","-jar","repo-connector-1.5.4.jar"]
CMD ["-start"]
答案 1 :(得分:0)
请你检查一下: “RUN ls -la /home/smartling/flagship/repo-connector-1.5.4 /”
检查文件(repo-connector-1.5.4.jar)是否具有运行所需的权限。如果没有,请使用chmod并授予jar权限。
命令如下:
RUN [“chmod”,“+ x”,“/ home /smartling / flagg / trip-connectionctor.5.5.4 /repo-connector-1.5.4.jar”]
在#确认文件在那里之后放置上面的命令 RUN ls -la /home/smartling/flagship/repo-connector-1.5.4 /