--detach, -d runs a container in the background and print container ID. It will allow you to run your container in the background without having to have your terminal (command line/command prompt) open. I usually run the command with the
-d flag when I don't want to keep an open tab on my terminal, or when I don't want to see all the outputs (
STDERR) created while my container is running.
--volume, -v flag is passed when you want to bind mount a volume. The
-v flag takes an argument that consist of three fields separated by
:. Some of these fields can be omitted in certain cases. In our case we ommit the third field. We pass
/my-files as the first option, which represents the location of our files in our host machine, the one we are writing on. And we pass
usr/local/apache2/htdocs as the second option, which represents the
htdocs folder in the container. The
-v flag allow you to bind your local files to the container files. So, you can now write to the container as you make changes on your local files.
Does it help? Let me know if you need any further clarification.