Docker bus error

bus error - Problem Description

I have a C++ executable (.exe) that runs perfectly on my host machine.
However, when I run it inside a Docker container, it immediately crashes with:

Bus error
infinity times

The same binary runs fine outside Docker on the same system.

What I’ve Checked So Far

  1. Dependencies:
    Verified using ldd - all required libraries are present
  2. Shared Memory Size:
    Tried increasing shared memory:

docker run --rm -it --shm-size=1g my_image ./program.exe
→ Still crashes with the same Bus error.

  1. Shared Memory Usage:
    The program allocates almost all of /dev/shm, so the issue is not insufficient memory,
    but rather an invalid memory access (inside or near shared memory).

  2. Debugging with GDB:
    The crash happens during a memory operation

no core dump created
The problem not disappears after a full cleanup or reboot

What could cause a Bus error inside a Docker container
when the exact same binary runs fine on the host?

Docker containers are always based on an image, created with a Dockerfile. Which image or Dockerfile did you use?

I’m using a custom base image that I built previously.
It has been used as the base for several other containers without any issues,
so the base image itself should be stable.

For this application, I created a separate Dockerfile that adds the specific dependencies my app needs, using that same base image.

I am still confused. The post is tagged with Linux, but you mention an .exe file, which is usually used with Windows.

1 Like

Is it safe to assume that your image uses .dotnet or mono to run the exe file? Can you please share your Dockerfile and the exact error message?

1 Like

Hey
It turns out that the problem was a lack of shared memory- I assigned more ( — shm-size “3g“) and the error gone.
Tnx u all!