Problems with DNS when using docker with vagrant

I am using Docker and Docker Compose with a Vagrant VM. I am using an existing Vagrant image with docker and docker-compose. The docker daemon inside the machine is having problems resolving domains. My vagrant file looks like this:

    Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64" 
# access a port on your host machine (via localhost) and have all data forwarded to a port on the guest machine.
config.vm.network "forwarded_port", guest: 9092, host: 9092
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "~/Workplace/vagrant-demo", "/data"
config.vm.provider "virtualbox" do |vb|
    vb.name = 'docker-compose-vm'
    vb.memory = 4096
    vb.cpus = 1
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.provision :docker
# install docker-compose into the VM and run the docker-compose.yml file - if it exists -  whenever the  VM starts (https://github.com/leighmcculloch/vagrant-docker-compose)
config.vm.provision :docker_compose
end

Once provisioned I ssh into the machine and run docker-compose up to build my docker containers and start them. One of my container is an express app which sends emails using the sendgrid API. However it is unable to hit the sendgrid API and I am getting an error.

I tried to debug this using this article. However nothing so far seems to work.