What unit does the docker run "--memory" option expect?

Classic case of RTFM on my part. The --memory option supports a unit suffix so we don't need to calculate the exact byte number:

 -m, --memory=""
      Memory limit (format: <number>[<unit>], where unit = b, k, m or g)

   Allows you to constrain the memory available to a container. If the
   host supports swap memory, then the -m memory setting can be larger
   than physical RAM. If a limit of 0 is specified (not using -m), the
   container's memory is not limited. The actual limit may be rounded up
   to a multiple of the operating system's page size (the value would be
   very large, that's millions of trillions).

So, to start a container with a 1 GB memory limit as described in the question, both of these commands will work:

$ docker run --memory 1g ... 
$ docker run --memory 1073741824 ...

The --memory-reservation and --memory-swap options also support this convention.

Tags:

Docker