Make the test for the 'docker_opts' grain more robust.

Fixes #2982