I have built a docker Container named ubuntu-comp and run it with a volume by this command:
sudo docker run -v /home/vivek/PersonalSet/OJBh/Judge/folderrun/:/home/folderrun/ -d ubuntu-comp
This command runs successfully. Now I want to execute a command to run a file called c.out and store the output (STDOUT) in a text file called c.txt. Both files are stored in the volume directory.
Normally I’d use the command /home/folderrun/c.out > /home/folderrun/c.txt. This works fine if I run the Command in interactive mode, i.e. with the -it flag.
but when i run the following command:
sudo docker exec -it focused_wilbur /home/folderrun/c.out > /home/folderrun/c.txt
I get the following error:
bash: /home/folderrun/c.txt: No such file or directory
I need a fix, Thanks in advanced for any help offered.
>Solution :
You can do it by passing your command to /bin/sh like this
sudo docker exec -it focused_wilbur /bin/sh -c "/home/folderrun/c.out > /home/folderrun/c.txt"