The build command (^C-^B) was escaping ~/mydockerimagedir into the nonexistent \~/mydockerimagedir. I fixed by removing shell-quote-argument from the end of compilation-start.
As this argument appears to be automatically set to the directory containing the Dockerfile, I couldn't find a good alternative to modifying the dockerfile-mode.el. Did I miss something? If you agree this makes sense, I will create a PR.