How to fix Error response from daemon: invalid tmpfs size in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 209 views

This error occurs when specifying a tmpfs mount size in an invalid format. Docker expects the size as an integer (bytes) or with proper suffixes like 'k', 'm', or 'g' for kilobytes, megabytes, or gigabytes.

Quick fix

Fixes Error response from daemon: invalid tmpfs size

# For docker run, look for --tmpfs or --mount flags
docker run --tmpfs /tmp:size=invalid_value myimage

# For compose files, check tmpfs sections
cat docker-compose.yml | grep -A 5 tmpfs
  1. Check your current tmpfs configuration
  2. Use correct size format for docker run
  3. Fix Docker Compose tmpfs size for v2+
  4. Use the short syntax alternative
docker โ€” error
# For docker run, look for --tmpfs or --mount flags
docker run --tmpfs /tmp:size=invalid_value myimage
# For compose files, check tmpfs sections
cat docker-compose.yml | grep -A 5 tmpfs
Error response from daemon: invalid tmpfs size

What this error means

The "invalid tmpfs size" error in Docker indicates that the tmpfs mount size you specified is in an incorrect format. A tmpfs (temporary filesystem) is a RAM-based filesystem that Docker can mount into containers for high-speed temporary storage. Docker requires tmpfs size values to be specified either as plain integers (representing bytes) or with size suffixes. When using Docker Compose v2+, the size must be a pure integer without quotes. The older string notation like "100m" may no longer work in newer versions of Docker Compose, causing this error. This issue commonly appears when migrating from Docker Compose v1 to v2, or when copying configuration examples that use an outdated syntax. The compose-spec requires size to be an integer, but older implementations supported string notation with suffixes.

Typical symptoms

  • docker run or docker-compose up fails with 'invalid tmpfs size' error
  • Error message: 'services.*.volumes.*.tmpfs.size must be a integer'
  • Tmpfs mounts work without size option but fail when size is specified
  • Docker Compose config generates quoted values causing the error
  • Migration from Docker Compose v1 to v2 breaks existing tmpfs configurations

Common causes

  1. Size value specified as a string with quotes instead of integer (e.g., "100m" instead of 104857600)
  2. Using Docker Compose v2+ with old string notation for size (e.g., size: '1g')
  3. Invalid size suffix or format (e.g., '100mb' instead of '100m')
  4. Missing or malformed size unit (e.g., '100' vs '100m' vs 104857600)
  5. Negative or zero size value specified
  6. Size exceeds available system memory

How to fix "Error response from daemon: invalid tmpfs size"

1Check your current tmpfs configuration

First, identify where the invalid size is specified. Check your docker run command or docker-compose.yml:

bash
# For docker run, look for --tmpfs or --mount flags
docker run --tmpfs /tmp:size=invalid_value myimage

# For compose files, check tmpfs sections
cat docker-compose.yml | grep -A 5 tmpfs

Look for patterns like:
- size: "100m" (quoted string - problematic in v2)
- size: 100m (unquoted string - may not work)
- o: "size=invalid" (invalid format in options)

2Use correct size format for docker run

When using docker run with --tmpfs flag, specify size in the mount options:

bash
# Correct format with size suffix
docker run -d --tmpfs /tmp:size=100m myimage
docker run -d --tmpfs /tmp:rw,noexec,nosuid,size=65536k myimage

# Using --mount flag (recommended)
docker run -d --mount type=tmpfs,destination=/tmp,tmpfs-size=104857600 myimage

Valid size suffixes for --tmpfs:
- k or K - kilobytes
- m or M - megabytes
- g or G - gigabytes

For --mount flag, use tmpfs-size with bytes or suffixed values.

3Fix Docker Compose tmpfs size for v2+

Docker Compose v2 requires tmpfs size as an integer (bytes). Update your docker-compose.yml:

Wrong (causes error):

yaml
services:
  myapp:
    image: myimage
    volumes:
      - type: tmpfs
        target: /tmp
        tmpfs:
          size: "100m"  # String - will fail

Correct (use integer bytes):

yaml
services:
  myapp:
    image: myimage
    volumes:
      - type: tmpfs
        target: /tmp
        tmpfs:
          size: 104857600  # 100MB in bytes (no quotes!)

Common size conversions:
- 64MB = 67108864
- 100MB = 104857600
- 256MB = 268435456
- 512MB = 536870912
- 1GB = 1073741824
- 2GB = 2147483648

4Use the short syntax alternative

Docker Compose also supports a short syntax for tmpfs that allows string suffixes:

yaml
services:
  myapp:
    image: myimage
    tmpfs:
      - /tmp:size=100m,mode=1777
      - /run:size=64m

Or as a simple list (uses default size - 50% of host RAM):

yaml
services:
  myapp:
    image: myimage
    tmpfs:
      - /tmp
      - /run

The short syntax tmpfs: at service level handles size differently than the long volumes: syntax.

5Create tmpfs volumes with docker volume create

For reusable tmpfs volumes, create them with proper options:

bash
# Create a 100MB tmpfs volume
docker volume create --driver local \
    --opt type=tmpfs \
    --opt device=tmpfs \
    --opt o=size=100m,uid=1000 \
    my_tmpfs_volume

# Use in docker run
docker run -v my_tmpfs_volume:/tmp myimage

In docker-compose.yml with volumes:

yaml
volumes:
  tmpfs_vol:
    driver_opts:
      type: tmpfs
      device: tmpfs
      o: "size=100m"  # String allowed here

services:
  myapp:
    image: myimage
    volumes:
      - tmpfs_vol:/tmp
6Verify Docker and Compose versions

Check your Docker and Docker Compose versions to understand which syntax is supported:

bash
docker --version
docker compose version
# or for older standalone compose
docker-compose --version

Docker Compose behavior by version:
- v1 (docker-compose): Supports string notation like "100m"
- v2 (docker compose): Requires integer for tmpfs.size in long syntax

If using Docker Compose v2 and you need string notation, use the short tmpfs: syntax instead of the long volumes: syntax with type: tmpfs.

Advanced notes

Understanding tmpfs size defaults: If you don't specify a size, tmpfs defaults to 50% of host RAM. This can be dangerous in production as containers could consume significant memory. Always set explicit size limits.

shm_size vs tmpfs size: Docker also has shm_size for /dev/shm which supports string notation:

yaml
services:
  myapp:
    shm_size: '2gb'  # String allowed for shm_size

Compose spec vs implementation: The compose-spec formally requires size as integer, but implementations vary. Docker Compose v2 strictly follows the spec, while older versions were more lenient.

Debugging compose config: Check what Docker Compose generates:

bash
docker compose config

If you see quoted size values like size: "104857600", that's a bug in compose config output that causes the "must be a integer" error.

Memory considerations: tmpfs uses RAM, so:
- Monitor host memory when using large tmpfs mounts
- Container memory limits (--memory) don't include tmpfs by default
- Multiple containers with large tmpfs can exhaust host memory

Permissions with tmpfs: You may also need to set mode and ownership:

bash
docker run --mount type=tmpfs,destination=/tmp,tmpfs-size=100m,tmpfs-mode=1777 myimage

Frequently asked questions

What does "Error response from daemon: invalid tmpfs size" mean?
The "invalid tmpfs size" error in Docker indicates that the tmpfs mount size you specified is in an incorrect format. A tmpfs (temporary filesystem) is a RAM-based filesystem that Docker can mount into containers for high-speed temporary storage. Docker requires tmpfs size values to be specified either as plain integers (representing bytes) or with size suffixes.
How do I fix "Error response from daemon: invalid tmpfs size"?
This error occurs when specifying a tmpfs mount size in an invalid format. Docker expects the size as an integer (bytes) or with proper suffixes like 'k', 'm', or 'g' for kilobytes, megabytes, or gigabytes.
What causes "Error response from daemon: invalid tmpfs size"?
Size value specified as a string with quotes instead of integer (e.g., "100m" instead of 104857600) Using Docker Compose v2+ with old string notation for size (e.g., size: '1g') Invalid size suffix or format (e.g., '100mb' instead of '100m')
Is the "Error response from daemon: invalid tmpfs size" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading