0

I want to add a JAR in a new image. Whenever i build the new image with the COPY command the build passes but whenever i go to the container in bash the file is not present and my Jmeter test fails.

I want to add the tika-app-1.20.jar to my new image that is using a FROM blazemeter/taurus.

I have tried the add command.

I am building the new docker image in the directory where the jar is located.

FROM blazemeter/taurus 
COPY tika-app-1.20.jar ~/.bzt/jmeter-taurus/5.1.1/lib/

Apparently the build passes but the file is not added in the image. I have no idea why.

Thank you in advance for any help.

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • could you share complete dockerfile and docker-compose.yml ? – Andrea Sep 20 '19 at 07:18
  • I do not have a docker-compose.yml, the complete docker file is the two line posted above "FROM blazemeter/taurus COPY tika-app-1.20.jar ~/.bzt/jmeter-taurus/5.1.1/lib/" – Aymeric Wilmotte Sep 20 '19 at 07:20
  • can you try with the absolute path instead of relative path in container? – Pacifist Sep 20 '19 at 07:21
  • Are you trying to Copy a file from host to container? – Tej Sep 20 '19 at 07:24
  • Whenever i try to do it with /user/myuser/test/tika-app.1.20.jar it does a build error and cannot find the file or directory. Is there something special is should put into the relative path? – Aymeric Wilmotte Sep 20 '19 at 07:25
  • @Tej Yes i am trying to copy a file from host to the image. So whenever i build the image the file would be present – Aymeric Wilmotte Sep 20 '19 at 07:25
  • Did you try with this method? https://stackoverflow.com/questions/22907231/copying-files-from-host-to-docker-container – Tej Sep 20 '19 at 07:29
  • @AymericWilmotte Sorry for the confusion, But I was talking about the relative path of container: ~/.bzt/jmeter-taurus/5.1.1/lib/. Could you please change this to absolute path and try. – Pacifist Sep 20 '19 at 07:32
  • @Tej Yes that method would add the file to the running container. But i want the file to be added to the docker image not the actual running container. Because i will need to start a container with this image quite often. So it would not be possible to copy the file into the new running container each time. – Aymeric Wilmotte Sep 20 '19 at 07:33
  • you are not creating any user so you should not try `/user/myuser/test/tika-app.1.20.jar `, try to `ls /root/` you will see the files or `/root/.bzt/jmeter-taurus/5.1.1/lib/` or most better to verify `docker exec -it container_id bash -c "ls ~/` or try to print the full path `pwd` – Adiii Sep 20 '19 at 07:33
  • `docker exec -it container_name bash -c "cd ~/ && pwd && ls"` you will see the file and path – Adiii Sep 20 '19 at 07:37
  • @Adiii Your solutions worked. Than alot for the help. Indeed with the absolute path is works. Thank you adii for the /root/ I have completely forgotten that existed ^^. It is resolved thank you ! – Aymeric Wilmotte Sep 20 '19 at 07:48
  • 1
    Also @Pacifist U were right :) – Aymeric Wilmotte Sep 20 '19 at 07:48
  • perfect if it solved the issue. pls accept answer this informs the community, a solution was found. Otherwise, others may think the question is still open and may want to post (more) answers. You'll earn points and others will be encouraged to help you. Welcome to Stack! – Adiii Sep 20 '19 at 07:53

2 Answers2

0

you are not creating any user so you should not try /user/myuser/test/tika-app.1.20.jar, try to ls /root/ or ls ~/ you will see the files or /root/.bzt/jmeter-taurus/5.1.1/lib/.

Also better to better to debug using docker exec.

docker exec -it container_name bash -c "cd ~/ && pwd && ls"

This will return the about path of the file.

which should be like /root/.bzt/jmeter-taurus/5.1.1/lib/.

Adiii
  • 54,482
  • 7
  • 145
  • 148
0

You can execute Docker RUN directive to download the tika-app.jar to the desired location like:

from blazemeter/taurus
RUN mkdir -p ~/.bzt/jmeter-taurus/5.1.1/lib/ \
    && wget -P ~/.bzt/jmeter-taurus/5.1.1/lib/ -c https://archive.apache.org/dist/tika/tika-server-1.20.jar

the directive will kick off mkdir command to create the folder if it doesn't exist and wget command to download the file to the specified location.

More information: How to Execute a Load Test Using the Taurus Docker Image

Dmitri T
  • 159,985
  • 5
  • 83
  • 133