How to get docker toolbox to work with .net core 2.0 project

With Docker Toolbox that’s a little tricky, but actually the core-2.0 has nothing to do here. It’s all about docker, docker-toolbox, and VS.

First of all:

Is this the way one is supposed to start up that docker services? I have tried running this executable, and it seems to be working.

Yes it is. If docker machine/services are running – that’s good!

Now, you have to realize that in docker, typically, the information about how/where the docker is running is kept in environment variables. The quickstart script not only starts the docker-machine for you and checks some basic things, it also sets up a couple of environmental variables so that later all commands like docker, docker-compose etc know where to look for the docker virtual machine. In your/our case that information mainly consists of an IP of the VM and a port number that Docker listens on.

.. and your Visual Studio has no knowledge of that, because, I bet on that, you have ran the VisualStudio from StartMenu or from Desktop icon or by double-clicking on a solution file, so it had no chance of getting the environmental variables from quickstart console.

The solution is quite simple: make sure that VS gets that information. That is, make sure it gets that environmental variables, and make sure that it gets the fresh state of them, because the IP/port may fluctuate sometimes. So don’t just copy them to your OS settings, because nothing will ever automagically refresh them..

The simplest way I found is to just close Visual Studio, run docker toolbox quickstart console, then run the VisualStudio from within that console, for example, for my VS2017 Community Edition:

Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
(.......snip..........)


                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

Start interactive shell
quetzalcoatl@LAP049 MINGW32 ~
$ /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Community/Common7/IDE/devenv.exe C:\\PATH\\TO\\MY\\SOLUTION.sln

The path is pretty long to write, even with TAB-completion, so usually make a tiny .sh script to run that for me.

BTW! Notice that the path to DEVENV must be unix-like (/c/Program\ Files...), because the mingw shell has to understand that, while the path to SOLUTION must be a normal windows path (c:\projects\foo\bar\..) because VisualStudio will try to read that after starting up.

Leave a Comment