- Docker Engine on Windows
- Install Docker
- Configure Docker with a configuration file
- Configure Docker on the Docker service
- Common configuration
- Default network creation
- Set Docker security group
- Proxy configuration
- How to uninstall Docker
- Prepare your system for Docker’s removal
- Uninstall Docker
- Clean up Docker data and system components
- Reboot your system
- Configure and troubleshoot the Docker daemon
- Start the daemon using operating system utilities
- Start the daemon manually
- Configure the Docker daemon
- Docker daemon directory
- Troubleshoot the daemon
- Troubleshoot conflicts between the daemon.json and startup scripts
- Use the hosts key in daemon.json with systemd
- Out Of Memory Exceptions (OOME)
- Read the logs
- Enable debugging
- Force a stack trace to be logged
- View stack traces
- Check whether Docker is running
Docker Engine on Windows
The Docker Engine and client aren’t included with Windows and need to be installed and configured individually. Furthermore, the Docker Engine can accept many custom configurations. Some examples include configuring how the daemon accepts incoming requests, default networking options, and debug/log settings. On Windows, these configurations can be specified in a configuration file or by using Windows Service control manager. This document details how to install and configure the Docker Engine, and also provides some examples of commonly used configurations.
Install Docker
You need Docker in order to work with Windows Containers. Docker consists of the Docker Engine (dockerd.exe), and the Docker client (docker.exe). The easiest way to get everything installed is in the quickstart guide, which will help you get everything set up and run your first container.
Before you can use Docker, you’ll need to install the container images. For more information, see docs for our container base images.
Configure Docker with a configuration file
The preferred method for configuring the Docker Engine on Windows is using a configuration file. The configuration file can be found at ‘C:\ProgramData\Docker\config\daemon.json’. You can create this file if it doesn’t already exist.
Not every available Docker configuration option applies to Docker on Windows. The following example shows the configuration options that do apply. For more information about Docker Engine configuration, see Docker daemon configuration file.
You only need to add the desired configuration changes to the configuration file. For example, the following sample configures the Docker Engine to accept incoming connections on port 2375. All other configuration options will use default values.
Likewise, the following sample configures the Docker daemon to keep images and containers in an alternate path. If not specified, the default is c:\programdata\docker .
The following sample configures the Docker daemon to only accept secured connections over port 2376.
Configure Docker on the Docker service
The Docker Engine can also be configured by modifying the Docker service with sc config . Using this method, Docker Engine flags are set directly on the Docker service. Run the following command in a command prompt (cmd.exe not PowerShell):
You don’t need to run this command if your daemon.json file already contains the «hosts»: [«tcp://0.0.0.0:2375»] entry.
Common configuration
The following configuration file examples show common Docker configurations. These can be combined into a single configuration file.
Default network creation
To configure the Docker Engine so that it doesn’t create a default NAT network, use the following configuration.
Set Docker security group
When you’ve signed in to the Docker host and are locally running Docker commands, these commands are run through a named pipe. By default, only members of the Administrators group can access the Docker Engine through the named pipe. To specify a security group that has this access, use the group flag.
Proxy configuration
To set proxy information for docker search and docker pull , create a Windows environment variable with the name HTTP_PROXY or HTTPS_PROXY , and a value of the proxy information. This can be completed with PowerShell using a command similar to this:
Once the variable has been set, restart the Docker service.
How to uninstall Docker
This section will tell you how to uninstall Docker and perform a full cleanup of Docker system components from your Windows 10 or Windows Server 2016 system.
You must run all commands in these instructions from an elevated PowerShell session.
Prepare your system for Docker’s removal
Before you uninstall Docker, make sure no containers are running on your system.
Run the following cmdlets to check for running containers:
It’s also good practice to remove all containers, container images, networks, and volumes from your system before removing Docker. You can do this by running the following cmdlet:
Uninstall Docker
Next, you’ll need to actually uninstall Docker.
To uninstall Docker on Windows 10
- Go to Settings >Apps on your Windows 10 machine
- Under Apps & Features, find Docker for Windows
- Go to Docker for Windows >Uninstall
To uninstall Docker on Windows Server 2016:
From an elevated PowerShell session, use the Uninstall-Package and Uninstall-Module cmdlets to remove the Docker module and its corresponding Package Management Provider from your system, as shown in the following example:
You can find the Package Provider that you used to install Docker with PS C:\> Get-PackageProvider -Name *Docker*
Clean up Docker data and system components
After you uninstall Docker, you’ll need to remove Docker’s default networks so their configuration won’t remain on your system after Docker is gone. You can do this by running the following cmdlet:
To remove Docker’s default networks on Windows Server 2016.
Run the following cmdlet to remove Docker’s program data from your system:
You may also want to remove the Windows optional features associated with Docker/containers on Windows.
This includes the «Containers» feature, which is automatically enabled on any Windows 10 or Windows Server 2016 when Docker is installed. It may also include the «Hyper-V» feature, which is automatically enabled on Windows 10 when Docker is installed, but must be explicitly enabled on Windows Server 2016.
The Hyper-V feature is a general virtualization feature that enables much more than just containers. Before disabling the Hyper-V feature, make sure there are no other virtualized components on your system that require Hyper-V.
To remove Windows features on Windows 10:
- Go to Control Panel >Programs >Programs and Features >Turn Windows features on or off.
- Find the name of the feature or features you want to disable—in this case, Containers and (optionally) Hyper-V.
- Uncheck the box next to the name of the feature you want to disable.
- Select «OK»
To remove Windows features on Windows Server 2016:
From an elevated PowerShell session, run the following cmdlets to disable the Containers and (optionally) Hyper-V features from your system:
Reboot your system
To finish uninstallation and cleanup, run the following cmdlet from an elevated PowerShell session to reboot your system:
Configure and troubleshoot the Docker daemon
Estimated reading time: 11 minutes
After successfully installing and starting Docker, the dockerd daemon runs with its default configuration. This topic shows how to customize the configuration, start the daemon manually, and troubleshoot and debug the daemon if you run into issues.
Start the daemon using operating system utilities
On a typical installation the Docker daemon is started by a system utility, not manually by a user. This makes it easier to automatically start Docker when the machine reboots.
The command to start Docker depends on your operating system. Check the correct page under Install Docker. To configure Docker to start automatically at system boot, see Configure Docker to start on boot.
Start the daemon manually
If you don’t want to use a system utility to manage the Docker daemon, or just want to test things out, you can manually run it using the dockerd command. You may need to use sudo , depending on your operating system configuration.
When you start Docker this way, it runs in the foreground and sends its logs directly to your terminal.
To stop Docker when you have started it manually, issue a Ctrl+C in your terminal.
Configure the Docker daemon
There are two ways to configure the Docker daemon:
- Use a JSON configuration file. This is the preferred option, since it keeps all configurations in a single place.
- Use flags when starting dockerd .
You can use both of these options together as long as you don’t specify the same option both as a flag and in the JSON file. If that happens, the Docker daemon won’t start and prints an error message.
To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon.json on Linux systems, or C:\ProgramData\docker\config\daemon.json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced.
Here’s what the configuration file looks like:
With this configuration the Docker daemon runs in debug mode, uses TLS, and listens for traffic routed to 192.168.59.3 on port 2376 . You can learn what configuration options are available in the dockerd reference docs
You can also start the Docker daemon manually and configure it using flags. This can be useful for troubleshooting problems.
Here’s an example of how to manually start the Docker daemon, using the same configurations as above:
You can learn what configuration options are available in the dockerd reference docs, or by running:
Many specific configuration options are discussed throughout the Docker documentation. Some places to go next include:
Docker daemon directory
The Docker daemon persists all data in a single directory. This tracks everything related to Docker, including containers, images, volumes, service definition, and secrets.
By default this directory is:
- /var/lib/docker on Linux.
- C:\ProgramData\docker on Windows.
You can configure the Docker daemon to use a different directory, using the data-root configuration option.
Since the state of a Docker daemon is kept on this directory, make sure you use a dedicated directory for each daemon. If two daemons share the same directory, for example, an NFS share, you are going to experience errors that are difficult to troubleshoot.
Troubleshoot the daemon
You can enable debugging on the daemon to learn about the runtime activity of the daemon and to aid in troubleshooting. If the daemon is completely non-responsive, you can also force a full stack trace of all threads to be added to the daemon log by sending the SIGUSR signal to the Docker daemon.
Troubleshoot conflicts between the daemon.json and startup scripts
If you use a daemon.json file and also pass options to the dockerd command manually or using start-up scripts, and these options conflict, Docker fails to start with an error such as:
If you see an error similar to this one and you are starting the daemon manually with flags, you may need to adjust your flags or the daemon.json to remove the conflict.
Note: If you see this specific error, continue to the next section for a workaround.
If you are starting Docker using your operating system’s init scripts, you may need to override the defaults in these scripts in ways that are specific to the operating system.
Use the hosts key in daemon.json with systemd
One notable example of a configuration conflict that is difficult to troubleshoot is when you want to specify a different daemon address from the default. Docker listens on a socket by default. On Debian and Ubuntu systems using systemd , this means that a host flag -H is always used when starting dockerd . If you specify a hosts entry in the daemon.json , this causes a configuration conflict (as in the above message) and Docker fails to start.
To work around this problem, create a new file /etc/systemd/system/docker.service.d/docker.conf with the following contents, to remove the -H argument that is used when starting the daemon by default.
There are other times when you might need to configure systemd with Docker, such as configuring a HTTP or HTTPS proxy.
Note: If you override this option and then do not specify a hosts entry in the daemon.json or a -H flag when starting Docker manually, Docker fails to start.
Run sudo systemctl daemon-reload before attempting to start Docker. If Docker starts successfully, it is now listening on the IP address specified in the hosts key of the daemon.json instead of a socket.
Important: Setting hosts in the daemon.json is not supported on Docker Desktop for Windows or Docker Desktop for Mac.
Out Of Memory Exceptions (OOME)
If your containers attempt to use more memory than the system has available, you may experience an Out Of Memory Exception (OOME) and a container, or the Docker daemon, might be killed by the kernel OOM killer. To prevent this from happening, ensure that your application runs on hosts with adequate memory and see Understand the risks of running out of memory.
Read the logs
The daemon logs may help you diagnose problems. The logs may be saved in one of a few locations, depending on the operating system configuration and the logging subsystem used:
Operating system | Location |
---|---|
RHEL, Oracle Linux | /var/log/messages |
Debian | /var/log/daemon.log |
Ubuntu 16.04+, CentOS | Use the command journalctl -u docker.service or /var/log/syslog |
Ubuntu 14.10- | /var/log/upstart/docker.log |
macOS (Docker 18.01+) | |
macOS (Docker /Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/console-ring | |
Windows | AppData\Local |
Enable debugging
There are two ways to enable debugging. The recommended approach is to set the debug key to true in the daemon.json file. This method works for every Docker platform.
Edit the daemon.json file, which is usually located in /etc/docker/ . You may need to create this file, if it does not yet exist. On macOS or Windows, do not edit the file directly. Instead, go to Preferences / Daemon / Advanced.
If the file is empty, add the following:
If the file already contains JSON, just add the key «debug»: true , being careful to add a comma to the end of the line if it is not the last line before the closing bracket. Also verify that if the log-level key is set, it is set to either info or debug . info is the default, and possible values are debug , info , warn , error , fatal .
Send a HUP signal to the daemon to cause it to reload its configuration. On Linux hosts, use the following command.
On Windows hosts, restart Docker.
Instead of following this procedure, you can also stop the Docker daemon and restart it manually with the debug flag -D . However, this may result in Docker restarting with a different environment than the one the hosts’ startup scripts create, and this may make debugging more difficult.
Force a stack trace to be logged
If the daemon is unresponsive, you can force a full stack trace to be logged by sending a SIGUSR1 signal to the daemon.
Linux:
Windows Server:
Get the process ID of dockerd Get-Process dockerd .
Run the executable with the flag —pid=
This forces a stack trace to be logged but does not stop the daemon. Daemon logs show the stack trace or the path to a file containing the stack trace if it was logged to a file.
The daemon continues operating after handling the SIGUSR1 signal and dumping the stack traces to the log. The stack traces can be used to determine the state of all goroutines and threads within the daemon.
View stack traces
The Docker daemon log can be viewed by using one of the following methods:
- By running journalctl -u docker.service on Linux systems using systemctl
- /var/log/messages , /var/log/daemon.log , or /var/log/docker.log on older Linux systems
Note: It is not possible to manually generate a stack trace on Docker Desktop for Mac or Docker Desktop for Windows. However, you can click the Docker taskbar icon and choose Diagnose and feedback to send information to Docker if you run into issues.
Look in the Docker logs for a message like the following:
The locations where Docker saves these stack traces and dumps depends on your operating system and configuration. You can sometimes get useful diagnostic information straight from the stack traces and dumps. Otherwise, you can provide this information to Docker for help diagnosing the problem.
Check whether Docker is running
The operating-system independent way to check whether Docker is running is to ask Docker, using the docker info command.
You can also use operating system utilities, such as sudo systemctl is-active docker or sudo status docker or sudo service docker status , or checking the service status using Windows utilities.
Finally, you can check in the process list for the dockerd process, using commands like ps or top .