Raji
Raji

Reputation: 887

Pass parameters to docker container using docker run command

I have created a docker image using Dockerfile mentioned below. There is a jar file in the image which needs few parameters to run it. I am passing the parameters using docker run command but it throws me error. Find the details below.

Dockerfile content

FROM ubuntu:14.04

ENV http_proxy http://http.proxy.nxp.com:7000
ENV https_proxy http://http.proxy.nxp.com:7000

RUN apt-get update

<set of lines for installing java is here>

ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

copy apache-jmeter-3.1 /apache-jmeter-3.1
RUN mkdir /jarloc
copy Test.jar /jarloc
RUN java -version
ENTRYPOINT [ java -jar /jarloc/Test.jar ]
RUN ls -l /jarloc

I created an image called as jmaster:1.0 and gave following command to spin the container.

docker run jmaster:1.0  http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv http://win_loc/soasta_parent/soasta/MyPOC/Dpc_data.csv 30 300 30

This gives me following error.

http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv: 1: [: missing ]

I am able to run this script from inside docker (docker run -it jmaster:1.0 /bin/bash). It gives me correct output. But when I try to pass the parameter in docker run command, I am getting this error. Am I passing this in a wrong way or is there any other way to do so?

When I go inside docker using 'docker run -it imagename /bin/bash' and execute following, I am getting correct results from jar.

/jarloc#java -jar Test.jar http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv http://win_loc/soasta_parent/soasta/MyPOC/Dpc_data.csv 30 300 30

Upvotes: 1

Views: 2226

Answers (1)

Miguel Marques
Miguel Marques

Reputation: 2846

Try with

ENTRYPOINT ["java","-jar","/jarloc/Test.jar"]

That should take the parameters in docker run

Upvotes: 2

Related Questions