COPY and ADD not working in Dockerfile
We have a docker file as
FROM bitnami/tomcat
EXPOSE 8080
EXPOSE 8009
ADD values.war /opt/bitnami/tomcat/data/
Except that the values.war file is never added when we
docker exec -it values /bin/bash
And check the directory /opt/bitnami/tomcat/data/
so that the war file is not copied.
However, we tried the following and when we connected to the docker container the file was copied
FROM bitnami/tomcat
EXPOSE 8080
EXPOSE 8009
RUN mkdir -p /var/app
ADD values.war /var/app
So this made us think the problem was with the directory and so we tried the following
FROM bitnami/tomcat
EXPOSE 8080
EXPOSE 8009
RUN ls -l /opt/bitnami/tomcat/data/
which gave a way out
ls: cannot access /opt/bitnami/tomcat/data/: No such file or directory
when creating an image
We think the problem is that FROM
image is bitnami/tomcat
using this directory as a volume or such. This is probably the bitnami / tomcat source image code, although we're not sure.
https://github.com/bitnami/bitnami-docker-tomcat/blob/master/9.0/Dockerfile
Any ideas on how to add the file to tomcat directory
source to share
This is one of the downsides of defining volumes inside the Dockerfile and the reason I don't recommend defining them there . Docker behavior is undefined when trying to modify files on a volume during build time, it might depend on your docker version or other external variables, so for portability it is best not to do this.
Since you are working with an image from the other side, I would raise the issue with them to remove the line (feel free to list them in your blog post for an explanation). Until that happens, you can check your build files from github and modify the Dockerfile to create your own version of your base image.
For reference, here's one of the notes about defining a volume in a Dockerfile from the docker docs (let's say 3x faster):
Changing the volume from the Dockerfile: If any of the build steps change the data in the volume after it has been declared, those changes will be discarded.
source to share
Just want to inform you that Bitnami Docker images are no longer declared VOLUME
in the Dockerfile, making it easier for our users to extend and customize docker images. I hope you find this change useful.
If you have further questions, please join our stack community at http://slack.oss.bitnami.com/ .
source to share