Home > other >  Docker run run the jar package, unable to generate the file, the code is as follows
Docker run run the jar package, unable to generate the file, the code is as follows

Time:10-23

Public class App
{

Public static void createNewFile (String fileName) {
The File f=new File (fileName);
Try {
F. reateNewFile ();
} the catch (IOException e) {
e.printStackTrace();
}
}

Public static void main (String [] args) throws InterruptedException
{
For (;; ) {
Try {
Thread.sleep (5000);
{} catch InterruptedException (e)
e.printStackTrace();
}
CreateNewFile (System. CurrentTimeMillis () + "");
System. Out.println (" Hello World!" );
}
}
}

Every 5 seconds to generate a file, a hello world output, but now only output hello world, file is not generated, don't know why
Docker loading centos7 system, the run command is as follows: docker run - d - v/media/sf_shared_file:/arpg - name test anapsix/alpine - Java Java jar/arpg/test. The jar

CodePudding user response:

By looking at the building of the run command, my guess is that the building host machine directory is/arpg, docker directory is/media/internal sf_shared_file
The original poster is to want to put the docker internal/media/sf_shared_file mount to the host machine/arpg
That is to say, the building Lord hope/arpg directory on the host see the generated files in the

If the above reasoning, that you seem to write backwards, should write - v/arpg:/media/sf_shared_file
  • Related