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

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.