How can you specify docker flags when a step is ran on Google Cloud Build?
I need to be able to specify --ipc=host to the docker command that runs a step. How do I do that?

A little more context.... When running the tests in one of my Google Cloud Build steps I am running into this error:

ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm).


This error is common when using pytorch, like I am, in docker but it is easily addressed with the flag --ipc=host. I don't know where to put this flag in my step's settings in the cloudbuild.yml.

Right now my step looks like this:

- id: 'run-tests'
  name: 'gcr.io/project/app:test-$BRANCH_NAME'
  entrypoint: 'bash'
  args:
    - '-c'
    - './bin/run-tests.sh'


I have tried adding the "ipc=host" to the args but those go to bash and not the docker command running the image.

I am going to try this option out myself, but I think you can build a container with ipc=host set. There is no option to do so during a docker build, but you can run a container with ipc=host, then create a new image using docker commit.

The basic premise is:

docker build
docker run --ipc=host
docker commit
docker push


More details and discussion here: https://github.com/moby/moby/issues/24743

5/4 Edit

While this works, the host may have the default shm setting, so you won't get a larger size. Instead, you should probably use docker run --shm-size=256m or similar to give your docker container more shared memory. This requires you to use the docker cloud builder image and configure your own docker run command.
