Answer the question
In order to leave comments, you need to log in
How to check if a file exists in a project if it is in another docker container?
Good afternoon!
Can you please tell me how to check the existence of a file in the project if it is in another docker container?
I am writing a function with jest tests and I want to display different messages depending on the existence of the file.
here is my code:
const doesExist = async () => {
return fsPromises.access(path.resolve() + "/../button.png", fs.constants.R_OK | fs.constants.W_OK)
.then(() => console.log("Файл существует");
.catch(() => console.log("Файл отсутствует");
}
Answer the question
In order to leave comments, you need to log in
Containers have separate file systems, i.e. they can communicate with each other via docker-network. In theory, you need to implement the image presence API in the backend container and pull it from the second container.
Or move resources shared by containers to the host machine and mount a directory with these resources in both containers. Then they will have a common file system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question