Docker in Windows, allocate more memory

Some installation / cheatsheet

Using Docker for Windows, Windows 10. 17.03.0-ce-win1 (10296). Channel: stable. 94675c5.

(Tip: Also install Kitematic, then you can right-click the running Docker icon and from there launch Kitematic for a nice GUI to see your containers.)

Basic commands:

# Create a tensorflow container:
docker run -it -p 8888:8888 -p 6006:6006 --name my_tensor_flow -v C:/Data/Docker:/data -v C:/Dev/python:/devpython tensorflow/tensorflow
# Run it in the future:
docker start -ai my_tensor_flow
# To connect to it with bash: (note: /notebooks is where the notebooks are kept, and we can already access the host's C:/Data/Docker in /data)
docker exec -it my_tensor_flow bash
# Then from the bash can run: tensorboard --logdir=/data/tensorboard/5/

Apart from the nice GUI, there are some useful commands from the command line:

docker stats [--all]
docker ps [--all]
docker container list [--all]

Allocating more memory

For my running container, docker stats showed (in “MEM USAGE / LIMIT”) that it was bounded by 1.934 GiB. Indeed, “Hyper-V Manager” showed “MobyLinuxVM” machine has only 2GB.

To allocate more memory: Docker’s settings, Advanced, set Docker’s memory e.g. to 8448MB. Docker will restart. Verify that “Hyper-V Manager” now shows “MobyLinuxVM” has assigned memory of 8448 MB. Run your previous container docker start -ai container-name, and now docker stats will show a memory bound of 8.003 GiB. Success.

Note: Running some

docker run -it -p ... --name ... --memory-swap -1 --memory 8g -v ...
will not work if your “MobyLinuxVM” doesn’t have enough assigned memory.

Leave a Reply

Your email address will not be published. Required fields are marked *