Docker Cheat Sheet for Deep Learning: The Basics — Exxact
In our previous Docker related blog: “ Is Docker Ideal for Running TensorFlow? Let’s Measure Performance with the RTX 2080 Ti “ we explored the benefits and advantages of using Docker for TensorFlow. In this blog, we’ve decided to document some common Docker commands and best practices that have helped us along the way. We welcome you to have a look, keep this blog as a reference, and if you think we left something out or know of a good tip/trick on Docker that’s saved you, let us know, and we’ll add it to the blog!
Basic Docker Terms You Should Know.
- Image: Docker images are the foundations of containers. Images are an immutable, ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime.
- Container: An instance of the image that can be executed as an independent application. The container has a mutable layer that lies on top of the image, dependencies isolated from the host machine.
- Volume: A volume is a specially-designated directory within one or more containers that bypasses the Union File System. Volumes are designed to persist data, independent of the container’s life cycle.
- Registry: A storage and content delivery system used for distributing Docker images.
- Repository: A collection of related Docker images, often different versions of the same application.
Note: There are more terms you may want to pick up on, check the glossary at the Docker website.
Launching Your Deep Learning Environment in Docker
Let’s take a look at some common Docker syntax by running a practical example. We’ll break it down piece by piece. Assuming your dependencies are installed, (or you’re using an Exxact deep learning workstation or server) you can fire up a TensorFlow container by entering the following command in a terminal:
nvidia-docker run -it -p 8888:8888 -p 6006:6006 -v ~/mywork:/benchmarks tensorflow/tensorflow:nightly-gpu bash
Breaking Down the Above Docker Command
-v ~/mywork:/benchmarks
Volume tag, This shares the folder ~/mywork
on your host machine to /benchmarks
folder inside your container. In generic terms -v /[host folder]:/[container folder]
Quick Tip: Starting a Stopped/Exited Container
1. Start the Container
docker exec -it [container name or ID] bash
Working With Docker Containers
docker container ls [OPTIONS]
-a
Show all containers (default shows just running)
-f
Filter output based on conditions provided
-format
Pretty-print containers using a Go template
-last, -n
Show n last created containers (includes all states)
-s
Display total file sizes
Originally published at https://blog.exxactcorp.com on March 12, 2019.