I presume you are trying to create the file in the container.
You have several problems going on, one of which @Yatharth Ranjan has addressed - you want echo
not cat
for that use.
The other is, your call is being parsed by the local shell, which is breaking it up into docker ... "hello world"
and a > ... system.txt
on your host system.
To get the pipe into file to be executed in the container, you need to explicity invoke bash in the container, and then pass it the command:
docker exec 12345 /bin/sh -c "echo \"hello world\" > /usr/somefile.txt"
So, here you would call /bin/sh in the container, pass it -c to tell it a shell command follows, and then the command to parse and execute is your echo "hello world" > the_file.txt
.
Of course, a far easier way to copy files into a container is to have them on your host system and then copy them in using docker cp: (where 0123abc is your container name or id)
docker cp ./some-file.txt 01234abc:/path/to/file/in/container.txt
COPY
directive to create the file in a reusable image?)