29. July 2017
NAV on Docker with Portainer
When you get used to it, working with the CLI for Docker / Windows Containers is quite easy but having a GUI is more convenient, especially for newcomers. A very good GUI for Docker / Windows Containers is Portainer, which is free and you can get services and support from the company behind it. I struggled for quite some time to get it up and running because a) the Docker community is still very Linux-dominated with Windows Containers being the newcomer and b) I had some trouble configuring the connection with our company proxy. Let me show you what needs to be done and how easy it is to get your NAV environment up and running with something like this as a result:
According to the Portainer documentation it should be possible to set an internal port proxy to access the Docker API from the Portainer Container like this
netsh interface portproxy add v4tov4 listenaddress=10.0.75.1 listenport=2375 connectaddress=127.0.0.1 connectport=2375
docker run -d -p 9000:9000 portainer/portainer -H tcp://10.0.75.1:2375
However I was unable to get this up and running and ended up doing the following which is a security problem as it makes the API available from your whole network, so you might not want to do that, but I didn’t find another way to get it done:
- Bind the API port to all IPs by changing C:\ProgramData\docker\config\daemon.json to
"hosts": ["tcp://0.0.0.0:2375", "npipe://"]
- Create a transparent network which we will then use for the Portainer container
docker network create -d transparent MyTransparentNetwork
- Run the Portainer container with
docker run -d --network=MyTransparentNetwork --name portainer --hostname portainer portainer/portainer
- Open portainer at http://portainer:9000
- Enter [containerhost]:2375 as your endpoint
Not exactly straight forward but it might be easier for you if you don’t have a mandatory proxy and also this might be the last time you use the CLI… 🙂
Actually using Portainer
If you have come that far you now have a nice web interface to work with your containers. You can pull images, create new containers, see the status and log entries of running containers, manage them and even a get a session inside the container within your browser:
Now how about running NAV inside it? Microsoft is starting to work with Docker (actual scope not yet defined) as you might have noticed when checking the agendas for Directions EMEA and TechDays (Directions NA to follow), therefore I am in the following not using Jakub Vanak’s excellent repo as in previous posts but a private one by Freddy Kristiansen of Microsoft. But you can achieve the same with either your own Dockerfiles or Jakub’s.
You can manually enter the necessary parameters in the GUI or you can use my template definitions by entering https://raw.githubusercontent.com/tfenster/templates/nav-and-iis/templates.json through Settings > Use custom templates > URL. With that you get three new templates with two being of interest for this scope: One for a generic NAV image where you have to provide your own DVD, one for the current dev environment (keep in mind that this is a Container, so you still need to install and setup your client).
If you have those in place, it really is incredibly easy to get your dev environment up and running. I’ve shortened the wait times a bit as you can see if you look at the timestamps but still from intialization to being ready for connections it takes about half a minute and from selecting the template to being ready it takes approximately a minute:
Before you can login you need to enter the Container either through the session feature in Portainer or by entering a PowerShell session as described here and calling
net user <login> <password
You could do that in Portainer but as everyone with admin access could then read your password, you probably don’t want to do that.
I really like the new possibilites Docker / Windows Containers bring from a development as well as from a production / hosting standpoint and really am happy how the NAV team is among the “early adopters” inside Microsoft. Just think back three years and here we are now, running NAV in the Cloud as full SaaS solution and also having it inside Windows Containers. Microsoft from my point of view is really moving in the right direction!