Multi Versions of Docker Swarm same server

Problem

Our company application deploys different versions of docker swarm to client servers. At no one point are our clients running the same version. Hence our application needs to support all these versions. As part of our internal unit tests, we need to test our software against these versions to ensure everything works as expected. There are a number of ways I can tackle this:

1: Host a different version of Swarm on 5 different machines. The down sides to this are

  • Tests are run across low latency network
  • Testing infrastructure costs are high
  • Tests could be interrupted by external factors, rendering the test inconsistent

2: Host different versions of Swarm in individual containers.

  • Docker in docker is known to have issues especially with inner volumes(which we’ll need to test)

3: Install multi versions of Swarm on the same host. Each swarm exposed by a different Unix socket. For the os is Ubuntu

Question

3 is my preferred options. My question is: Is this possible? Can I compile each version of docker? If yes How?

Or

Is there another solution I’m missing?