Building Docker File

Hi All I am new to Docker and getting confused in the section where they are creating Docker File. They have mentioned to copy the source code to /opt/. Just wanted to check if this is a mandatory step and the purpose of specifying this dir we can customize this dir and can give any other location also right

You can copy files to anywhere you like in the container.
By convention in Linux, third party applications are usually installed to /opt, just like they go to C:\Program Files in Windows.