Error: Unable to access jarfile when running docker container

北慕城南 提交于 2020-01-04 04:15:51

问题


I am getting the following error when trying to run a docker container:

Error: Unable to access jarfile

My Dockerfile is like this:

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&"]

Then I build

docker build -t smartlingflagship .

Everything comes back successful

The I run the container

docker run --rm --name smartlingconn smartlingflagship

And it comes back with the following error:

Error: Unable to access jarfile /home/smartling/flagship/repo-connector-1.5.4/repo-connector-1.5.4.jar -start&

Am I missing anything?


回答1:


I was able to resolve this by adding this to the bottom ENTRYPOINT ["java","-jar","repo-connector-1.5.4.jar"] CMD ["-start"]




回答2:


Could you please check the response of : "RUN ls -la /home/smartling/flagship/repo-connector-1.5.4/"

Check if the file(repo-connector-1.5.4.jar) is having the required permission to run. If not please use chmod and grant the jar the permission.

Command is as follow:
RUN ["chmod", "+x", "/home/smartling/flagship/repo-connector-1.5.4/repo-connector-1.5.4.jar"]

Place the above command after # Making sure the files are there
RUN ls -la /home/smartling/flagship/repo-connector-1.5.4/



来源:https://stackoverflow.com/questions/49184985/error-unable-to-access-jarfile-when-running-docker-container

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!