How does Vagrant differ from Ansible and Docker?
Vagrant can complement Ansible and Docker. It is used to spin virtual machines inside which you install Docker and test your Ansible playbooks. You describe desired VM configuration with Vagrantfile and then spawn them with vagrant up command. Then Vagrant software downloads one of shared boxes (VM templates, like bare ubuntu or centos, or with preinstalled software like laravel), and provisions it (executes setup instructions). There are several provisioners, like simple shell, or Ansible.

One of possible scenarios: you want to test mysql:5.7.24 image inside Docker 18.06.1-ce on Ubuntu 18.04. So you:


Spin up ubuntu/bionic64 box with Vagrant
Provision it with Ansible playbook that installs Docker 18.06.1-ce
Start Docker container based on mysql:5.7.24 image