I am trying to integrate an image library into my docker based project. In one of the supplied source files I see file exists() is failing. I have a directory on the host that I am using to debug the code (see path below). I am starting to think that my php code can’t see my directory on the host.
The code uses file_exists() to see if a certain module is at /opt/docker-substantiator/app/application/views/list.php. it is a pretty straightforward function call and I think this must be a Docker induced failure. I called getcwd and it is /app. Any idea why I can’t see if this file exist?. Remember, my php is running in a container.
You dont give enough information (Dockerfile, how the container is created, what volum does it have…) to get a valid reponse.
The only thing I can tell you for now is : containers do not share the host “/” directory so depending on how you set things the file might not be available or at an other place.
volumes:
data:
driver: local
jasperreports_data:
driver: local
networks:
net:
Thanks Sebt3. So my php code running in the container can’t see anything in the host volume? This will be an issue since the library I am trying to get working sticks the images uploaded into a dir there, and only keeps the address in the mysql. Is there a way to make the whole volume accessible from the PHP running in the container? I see the line
volumes:
./app:/app
Is this a bind mount? I thought a bind mount can only be setup in a Dockerfile, and I don’t know where that Dockerfile is located on my system. Would looking at the Docker logs help me in debugging this?
Here is some additional information.
When I run docker inspect I get:
richb201@richb201-XPS-13-9370:~$ docker inspect --format ‘{{json .Mounts}}’ 6ad | jq .
[
{
“Type”: “bind”,
“Source”: “/opt/docker-substantiator/app”,
“Destination”: “/app”,
“Mode”: “rw”,
“RW”: true,
“Propagation”: “rprivate”
}
]
This has been leading me to think that the problem is that the Propagation is rprivate (the default) rather than rshared. Is this the issue?
When I run:
richb201@richb201-XPS-13-9370:~$ docker exec 6adf ls -ls /app/assets/image_crud/views/list.php
8 -rwxrwxrwx 1 1001 134 5744 Feb 23 06:48 /app/assets/image_crud/views/list.php
I can see that the list.php file does exist! What is meant by the comment:
“The only thing I can tell you for now is : containers do not share the host “/” directory so depending on how you set things the file might not be available or at an other place.”?
I am not able to change the Propagation to “shared” to test my theory. You can see the way I created the volume
volumes:
./app:/app
Is there any example of how to set the vol-options ? Also what is the significance of using “volumes” rather than “volume”?