Had same problem. Two ubuntu 18.04.1 boxes. One recently installed, the other was recently upgraded from 16.04.5. In the first one I could import keys to install Scala & R without problems. In the second one the import process failed with the same error as you.
It seems that gpg imports keys launching a dirmng daemon. This process is the one that communicates through the network with keyserver.ubuntu.com.
To solve the problem, I launched dirmng prior to gpg this way:
sudo -i
dirmngr --daemon --homedir /root/key --debug-level guru --log-file dirmng.log
gpg -vv --debug-level 9 --ignore-time-conflict --no-options --no-default-keyring --homedir '/root/key' --no-auto-check-trustdb --trust-model always --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
Then gpg shows the dialog with dirmngr:
gpg: DBG: chan_3 -> KEYSERVER --clear hkp://keyserver.ubuntu.com:80
gpg: DBG: chan_3 <- OK
gpg: DBG: chan_3 -> KS_GET -- 0x2EE0EA64E40A89B84B2DF73499E82A75642AC823
gpg: DBG: chan_3 <- ERR 167804976 Invalid argument <Dirmngr>
gpg: keyserver receive failed: Invalid argument
gpg: DBG: chan_3 -> BYE
And dirmngr log file shows errors resolving keyserver.ubuntu.com:
2018-09-07 11:44:34 dirmngr[16174.6] DBG: chan_6 <- KS_GET -- 0x2EE0EA64E40A89B84B2DF73499E82A75642AC823
2018-09-07 11:44:39 dirmngr[16174.6] resolving 'keyserver.ubuntu.com' failed: Invalid argument
2018-09-07 11:44:39 dirmngr[16174.6] number of system provided CAs: 133
2018-09-07 11:44:44 dirmngr[16174.6] resolving 'keyserver.ubuntu.com' failed: Invalid argument
2018-09-07 11:44:44 dirmngr[16174.6] can't connect to 'keyserver.ubuntu.com': host not found
2018-09-07 11:44:44 dirmngr[16174.6] error connecting to 'http://keyserver.ubuntu.com:80': Invalid argument
2018-09-07 11:44:44 dirmngr[16174.6] command 'KS_GET' failed: Invalid argument
Why one box connected to the same network fails to resolve keyserver.ubuntu.com from dirmngr and the newer one succeeds? Why in the older box I could resolve keyserver.ubuntu.com with nslookup but dirmngr couldn't? I don't know. But the difference between the two boxes was in /etc/resolv.conf. I had added google DNS servers. Removing them from resolv.conf made dirmngr work.
nameserver 127.0.0.53
#nameserver 8.8.8.8
#nameserver 8.8.4.4
After this change, apt-key works. Hope this helps.