TensorBoard
Docker
Windows
Machine Learning
Deep Learning

How to use TensorBoard in a Docker container on Windows

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

Running TensorBoard in Docker on Windows is mostly a matter of three things: mount the log directory into the container, publish port 6006, and make TensorBoard listen on all container interfaces instead of only loopback. If any of those three pieces is missing, the browser on the Windows host usually cannot reach the dashboard.

The Basic Container Command

Assume your TensorFlow logs are stored in a local folder named logs under the current working directory. In PowerShell, a simple working command is:

powershell
1docker run --rm -it `
2  -p 6006:6006 `
3  -v ${PWD}\logs:/logs `
4  tensorflow/tensorflow:latest `
5  tensorboard --logdir=/logs --bind_all

Then open:

text
http://localhost:6006/

The important parts are:

  • '-p 6006:6006 publishes the container port to the Windows host'
  • '-v ${PWD}\logs:/logs makes the host log files visible inside the container'
  • '--bind_all tells TensorBoard to listen on 0.0.0.0 in the container'

Without --bind_all, TensorBoard often binds only to the container's loopback interface, which is not reachable through Docker's published port from the host browser.

Command Prompt Variant

If you are using cmd.exe rather than PowerShell, the path expansion syntax is different:

cmd
docker run --rm -it -p 6006:6006 -v %cd%\logs:/logs tensorflow/tensorflow:latest tensorboard --logdir=/logs --bind_all

That difference matters on Windows more than on Linux or macOS because shell path interpolation is not uniform.

Generate Logs In A Way TensorBoard Can Read

The container only visualizes event files that already exist in the mounted directory. For example, a simple TensorFlow script might write logs like this:

python
1import tensorflow as tf
2import datetime
3
4logdir = "logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
5writer = tf.summary.create_file_writer(logdir)
6
7with writer.as_default():
8    for step, value in enumerate([0.8, 0.6, 0.4]):
9        tf.summary.scalar("loss", value, step=step)
10
11writer.flush()
12print(logdir)

Run that on the Windows host, then point the Docker container at the parent logs directory. TensorBoard will discover the run automatically.

Why Docker Works Well Here

TensorBoard itself is lightweight, but machine-learning environments are often dependency-heavy. Running it in Docker avoids polluting the host Python installation and keeps the visualization environment consistent across machines.

This is especially useful when the training job itself already runs in a container. You can mount the same log volume into a separate TensorBoard container and inspect results without installing extra tools on Windows.

Common Windows-Specific Friction

The usual Windows problems are path sharing and filesystem permissions. Docker Desktop must be allowed to read the drive that contains your logs. If the mount silently fails, TensorBoard starts, but it shows no runs because /logs inside the container is empty.

A quick check is to open a shell in the same image and inspect the mounted directory:

powershell
docker run --rm -it -v ${PWD}\logs:/logs tensorflow/tensorflow:latest bash
ls -R /logs

If the files are not present there, the problem is the volume mount rather than TensorBoard.

Use Stable Host Paths For Repeated Work

For regular use, avoid relying on whichever folder happens to be your current directory. Mount an explicit path instead, such as a project log directory or a named Docker volume. That makes documentation and team handoffs clearer.

For example:

powershell
1docker run --rm -it `
2  -p 6006:6006 `
3  -v C:\ml\runs:/logs `
4  tensorflow/tensorflow:latest `
5  tensorboard --logdir=/logs --bind_all

That command is easier to reuse in build notes or scripts.

Common Pitfalls

The first pitfall is forgetting -p 6006:6006. Without port publishing, the service exists only inside the container network.

Another common mistake is leaving out --bind_all. TensorBoard may start successfully but still not be reachable from the Windows host.

People also point --logdir at the wrong in-container path. If the mount is ...:/logs, then --logdir=/logs must match it.

Finally, do not debug TensorBoard first if the mount is empty. On Windows, path and drive-sharing issues are more common than TensorBoard bugs.

Summary

  • Publish port 6006, mount the log directory, and use --bind_all.
  • Use PowerShell path syntax with ${PWD} or a fixed Windows path.
  • Confirm that event files are actually visible inside the container.
  • Open TensorBoard from the Windows host at http://localhost:6006/.
  • Most failures come from port publishing or volume-mount mistakes, not from TensorBoard itself.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.