I've found I can recreate this in this way:
Run docker container as such.
docker run --name gitlab-test -d -p 80:80 -v /host/user/gitlab-ce:/etc/gitlab gitlab/gitlab-ce:8.10.1-ce.0
Then change the gitlab.rb setting to set the external url to localhost and mattermost external url to 127.0.0.1.
Stop and start the docker container again. Gitlab works, mattermost 502s with the above error in the logs.
I'm wondering if this is a bug in gitlab's omnibus or a misunderstanding of mattermost setup.