Compose: shm_size option ignored

Created on 9 Nov 2018  路  2Comments  路  Source: docker/compose

Description of the issue

When I use the shm_size option in the compose file for a build it is being ignored.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.22.0, build f46880f
docker-py version: 3.4.1
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2o  27 Mar 2018

Output of docker version

Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:21:31 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:29:02 2018
  OS/Arch:          linux/amd64
  Experimental:     true

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  sut:
    build:
      context: .
      dockerfile: Dockerfile
      shm_size: 2gb
    command: 'bash -c "df -h"'
version: '3.5'

Steps to reproduce the issue

  1. Use this compose file with a generic linux image

Observed result

The output from the container command shows /dev/shm at 64m

Expected result

should be 2gb

arebuild kinquestion

Most helpful comment

Looks to me like it's working as intended:

$ cat Dockerfile 
FROM busybox
RUN df -h -k /dev/shm

$ cat docker-compose.yml 
version: '3.5'
services:
  test:
    build:
      context: .
      shm_size: '256m'
    command: 'df -k /dev/shm'

$ docker-compose build --no-cache
Building test
Step 1/2 : FROM busybox
 ---> 59788edf1f3e
Step 2/2 : RUN df -h -k /dev/shm
 ---> Running in 57525b883bae
Filesystem                Size      Used Available Use% Mounted on
shm                     256.0M         0    256.0M   0% /dev/shm
Removing intermediate container 57525b883bae
 ---> 05760024cce1

Successfully built 05760024cce1
Successfully tagged repro6333_test:latest

If you were expecting it to affect the size of /dev/shm of your running container, that's not what build.shm_size does. You'll want to set service.shm_size instead.

All 2 comments

Looks to me like it's working as intended:

$ cat Dockerfile 
FROM busybox
RUN df -h -k /dev/shm

$ cat docker-compose.yml 
version: '3.5'
services:
  test:
    build:
      context: .
      shm_size: '256m'
    command: 'df -k /dev/shm'

$ docker-compose build --no-cache
Building test
Step 1/2 : FROM busybox
 ---> 59788edf1f3e
Step 2/2 : RUN df -h -k /dev/shm
 ---> Running in 57525b883bae
Filesystem                Size      Used Available Use% Mounted on
shm                     256.0M         0    256.0M   0% /dev/shm
Removing intermediate container 57525b883bae
 ---> 05760024cce1

Successfully built 05760024cce1
Successfully tagged repro6333_test:latest

If you were expecting it to affect the size of /dev/shm of your running container, that's not what build.shm_size does. You'll want to set service.shm_size instead.

I was doing it wrong indeed, thank you for your explanation !

Have a nice day

Was this page helpful?
0 / 5 - 0 ratings