Error: Unable to access jarfile when running docke

2019-07-14 11:29发布

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?

2条回答
Anthone
2楼-- · 2019-07-14 12:04

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/

查看更多
我只想做你的唯一
3楼-- · 2019-07-14 12:10

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

查看更多
登录 后发表回答