If you find a way to install 9.5 on Ubuntu 17.10, I’d love to hear about it. I think that it should be possible with Docker, but I’ve not yet managed.
My solution thus far has been using the docker development environment in discourse/bin/docker, which has a few quirks, but it works.
I actually got DIscourse to work just fine with 9.6, but then I couldn’t restore the import I’d done to a production container.