In this video, learn how to locate and edit some of the most common parameters in the daemon.json file that configures the Docker daemon.
- [Instructor] The docker package that we installed for power cell gave us a lot of commands to help manage containers and to manage the images that we would load into those containers. But it didn't give us a lot of functionality in terms of managing docker itself. I'm going to close out of power shell and we are going to take a look at the docker for windows application. I downloaded it from docker and installed it on this windows server. So let me right click on the icon and choose settings.
From here I have the ability to set a lot of parameters about how docker will run. The one I want to focus on at this point is the Daemon or the background service that supports docker as a container management tool. When you look at this page, there's really not a lot to modify here. Even if I switch it to advanced all I see is the contents of some file that I can modify along with a warning that doing so might prevent docker from even starting.
This information that you are seeing here is actually the contents of a file that you can find on the hard drive of your server after you install docker for windows. So let me go ahead and close this graphical tool and I'm going to open a file browser and browse into the C drive in program data inside docker to the config directory. Now if you haven't installed docker for windows all you'll find in this directory is the key dot json file.
What we are looking for is the Daemon dot json file, in fact let me go to view and start showing file name extensions so that we can see them. Daemon dot json is the configuration information about how the docker daemon will run at boot or at any time that the daemon needs to restart. If I were to double click on this I would see what right now is a pretty empty list. There is not a lot of configuration detail in our daemon dot json file at this point.
If I'm going to start editing this file I do need to keep in mind the warning that we saw in the docker for windows tool. So I'm going to copy this daemon dot json file and I'm going to rename this to give it an old school file extension to remind me that this is a backup of the daemon file. This will be important later if I make a change that stops the daemon from working. I can simply restore this B A K file as the json file that worked.
There are a lot of parameters that could be added to this start up file and not all of them were intended for windows containers. I wanted to look at a sample json file and consider some of the more common things that you may want to modify. You can see that there are several options here but the first one I want to bring to your attention is graph. Not everyone likes keeping all of the files used by their applications right next to the operating system.
So you have the ability to change the location of containers and images. If I wanted to change the location of my image files I could select this, copy it, and paste it into my configuration file and inside these quotation marks I could type d:\\imgctr and this would have the effect of using my new image center directory on my D drive as the local path for containers and images.
This is the kind of setting that you really should make before you start pulling images and running containers. Otherwise, you are going to confuse docker and your users when they try to open containers and images that are no longer where windows used to be able to find them. You are going to need to cut everyone off while you move files back and forth and then restart the service. This change would be applied the next time the docker daemon starts and that's an important point to consider when you make changes to this file.
As you modify the start up options of the docker daemon on a server that's been in use even for just a little while make sure you assess what effect your changes will have on existing containers as well as the developers and users that are accessing them. Another common feature that I wanted to point out is the transport layer security feature. In addition to saying TLS verify equals true, you would add the local path to the PEM files of the route certificate authority, this servers certificate, and the public key.
Later in the course, we will take a look at registries and repositories for storing images. If you have an on premise image repository, you may need to add it here as one of the insecure registries. The makers of docker document several parameters that can be set in this json file. But as I said before, not all of them would apply to a windows container environment. The most important thing to remember is to create this backup before you save changes.
That simple step has pulled me out of a jam in more than one instance. It gives you the freedom to modify the startup parameters of the docker daemon so that it will run the way you want. It allows you to work with your developers on settings that will make their environment more secure, more flexible, or whatever type of more is right for you.
- Physical host environments
- Virtual host environments
- Installing and creating Windows containers
- Creating Hyper-V containers
- Creating, tagging, and pushing images
- Removing images
- Configuring startup options
- Working with PowerShell, Docker daemon, and Azure
- Managing container networking
- Managing data volumes, resources, and repositories