when I build and then run docker the code works fine and prints whatever I want to the command line. However, within my code, I have places where I write to a text file. My local machine doesn't reflect the text file changes.
EXAMPLE
print("Hello World)
this prints to my command line when I build and run Docker.
f = open("/feed.txt", "w")
f.write(str(time))
the feed.txt file is still blank even with this code.
What is happening here?
/feed.txt
really the correct path?/feed.txt
is absolute path. Will write to afeed.txt
file in your root directory (if the script has the permission to do it). Remove the/
and should work.close
the file handle (or use awith
statement which handles this for you).