Search code examples
node.jsdockerdockerfileserve

Why my DockerFile is unable to read and write data to any directory on server even it exists, while locally working ok on my system


This is Docker File

scription here

In the above my server is unable to read and write data to any directory on server while directory exists but it shows no such file or directory open and error shows. While it's working ok on my system locally.


Solution

  • When you bind map a directory on the host into a container using -v /home/hali/Downloads/thumbnail:/src/app, the directory will be accessible inside the container on the path /src/app.

    Your program expects to find it at /home/hali/Downloads/thumbnail, so it doesn't work.

    You can fix it in two ways:

    • Change the program to write the thumbnails to /src/app.
    • Change the name the directory is mapped to inside the container. If you map it using -v /home/hail/Downloads/thumbnail:/home/hail/Downloads/thumbnail the directory will be known under the same name inside the container as it is outside the container.