Closed xni closed 10 years ago
I haven't faced with any problems on file creation.
This is my changes in MyContainer.java
:
private void run() throws IOException {
LOG.info("Running Container on {}", this.hostname);
// http://stackoverflow.com/questions/617414/create-a-temporary-directory-in-java
final File temp;
final File parent_dir = new File("/opt/docker-output");
temp = File.createTempFile("docker-", null, parent_dir);
temp.delete();
temp.mkdir();
final File output = new File(temp, "output.txt");
FileWriter fr = new FileWriter(output);
fr.write("Test: ok!");
fr.close();
}
Then I performed
$ sudo mkdir /opt/docker-output
$ sudo chown yarn /opt/docker-output
$ sudo chgrp yarn /opt/docker-output
on nodes.
Result:
$ head /opt/docker-output/*/output.txt
==> /opt/docker-output/docker-253786542757618065.tmp/output.txt <==
Test: ok!
==> /opt/docker-output/docker-3370875717565256190.tmp/output.txt <==
Test: ok!
==> /opt/docker-output/docker-5835337523467844749.tmp/output.txt <==
Test: ok!
==> /opt/docker-output/docker-8378056582861110864.tmp/output.txt <==
Test: ok!
==> /opt/docker-output/docker-8617089359044222916.tmp/output.txt <==
Test: ok!
I don't know how files are created without extra directory creation (/opt/docker-output
), but it's okay in the moment to use this approach.
I think I'll be great if a container will be able to create some files, independent and secure from other running containers on the same node. I think, this can be done. Creating temporary per-container folders will allow us to use them for docker shared volumes (http://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume) to store a temporary result.