This evening, by checking the data, I learned that to make the docker container run in the background, you should add tail - f /dev/null
after the command. However, I don’t understand the meaning of each letter in the command tail - f /dev/null
. I only know that it can make the docker container run in the background. I want to know the meaning of each letter in the command tail - f /dev/null
,Thanks in advance.
2
Answers
There is a typo in your command. Remove the whitespace between – and f then it should work.
tail is responsible to read the last 10 lines of a file -f parameter means follow all lines which will be added to the file.
This is the reason why the terminal will stay open.
/dev/null is a Linux device.
I think you mean
tail -f /dev/null
From
man tail
:/dev/null
is a virtual device file that will appear totail
as if it were a "normal" file.In plain English, this will make
tail
keep waiting for new data in/dev/null
, but there will never be any since it’s a special type of device (essentially a black hole).