I followed all the instructions in this page but encountered two errors.
Running with verbose mode gives more information on the errors, i.e.:
bazel build -c opt //tensorflow/cc:tutorials_example_trainer --verbose_failures
The first was permission denied:
mount("none", "/", NULL, MS_REC | MS_PRIVATE, NULL): Permission denied
The solution is to run the docker container with the –privileged flag. I am not sure exactly which privileged is needed.
Ran again and encountered the second error. It requires zlib which I have not installed in my image.
apt-get install zlib1g-dev
Afterwards I am able to finish compiling.