I have two docker containers: producer and consumer.
Consumer container has two volumes:
VOLUME ["/opt/queue/in", "/opt/queue/out"]
docker-compose.yml
consumer:
image: consumer
producer:
image: producer
volumes_from:
- consumer
Producer puts file in /opt/queue/in
directory and consumer reads file from that dir and moves it to the /opt/queue/out
. The problem is that consumer is written in Java and following Java code returns -1
(operation failed).
new File('/opt/queue/in/in_file').renameTo(new File('/opt/queue/in/in_file'));
When I try to move file from command line there is no error. File is moved correctly. Why this is happening? How can I diagnose what is the problem?
The javadoc for File.renameTo specifically says that it may not be able to move a file between different volumes, and that you should use Files.move if you need to support this case in a platform independent way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With