Skip to content
GitLab
Next
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #281199

Cannot set shm size when using Docker-in-Docker

Summary

When using Docker-in-Docker in the GitLab CI runner, there doesn't seem to be a way to set the shared memory size, either of the "outer" Docker container or the "inner" Docker containers.

Steps to reproduce

Create a CI pipeline with .gitlab-ci.yml file like this:

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_SHM_SIZE: 2000000000

image:
  name: docker/compose:1.27.4
  entrypoint: ["/bin/sh", "-c"]

services:
  - docker:19.03.13-dind

build_stuff:
  script:
    - df /dev/shm
    - docker-compose build my_service
    - docker-compose run my_service

where the docker-compose.yml file is like this:

version: '3'

services:
  my_service:
    build: .
    command: df /dev/shm
    ipc: host
    shm_size: '8gb'

Example Project

https://gitlab.com/adamalton/docker-shm-test

Pipeline: https://gitlab.com/adamalton/docker-shm-test/-/jobs/843730271

What is the current bug behavior?

Both calls of the df /dev/shm command give the following output:

Filesystem           1K-blocks      Used Available Use% Mounted on
shm                      65536         0     65536   0% /dev/shm

So the SHM size is still set to 64MB, despite all attempts to increase it.

What is the expected correct behavior?

The call to df /dev/shm should give a reading of a larger amount of memory (either the 2GB from DOCKER_SHM_SIZE or the 8GB from shm_size).

Of course, it could be that I'm using the wrong technique/command/location for checking the shared memory size, but I have automated browser tests with Cypress which are persistently failing due to the Chromium process running out of memory and crashing, which don't fail when the Docker image is run on my laptop. So I'm pretty certain that GitLab CI is not allocating the requested amount of shared memory.

Output of checks

See above.

This bug happens on GitLab.com.

Edited Nov 13, 2020 by Adam Alton
Assignee
Assign to
Time tracking