Link Search Menu Expand Document

Docker

Docker containers allow you to define a VM-like environment specified by a series of steps in a Docker configuration file (Dockerfile), and then run your environment on various host platforms (e.g. Linux, Mac, Windows). We use Docker containers to run our Development Environment, as well as to run binaries on the Google Cloud platform.


Table of contents

  1. Installation
  2. Example Usage
    1. Building
    2. Running
    3. Stopping a run
  3. Suggested reading

Installation

We won’t be using Docker’s storage hub so you won’t really need to create an account. Docker asks you to create an account before downloading for Mac/Windows, but will allow you to use the direct download links below without an account.

Mac
Download and Instructions
Windows
Download and Instructions
(Note, do not Use Windows containers instead of Linux containers.)
Linux
Download
(other links there with instructions for Ubuntu/Debian/etc)

After installation you can verify Docker works by running the following from the command line:

$ docker run hello-world

Example Usage

Building

Build the environment specified by docker/Dockerfile, tagging the result with my_image, with the current directory as the source:

$ docker build -f docker/Dockerfile -t my_image .

Running

Run the latest variant of my_image, removing the container after it stops, mapping port 8080 locally to port 8080 in the container, naming the created container my_run:

$ docker run --rm -p 8080:8080 --name my_run my_image:latest

Stopping a run

Stop the container named my_run:

$ docker container stop my_run

Suggested reading


Back to top

“You may think using Google’s great, but I still think it’s terrible.” —Larry Page

Page last modified: May 30, 2022.