'Why does Docker Container exit immediately with exit code 1?

I took over a project and a necessary docker container doesn´t keep running, but instead exits immediately with code 1 after startup. My Dockerfile:

FROM ubuntu:20.04

RUN apt-get update
RUN apt-get install -y mariadb-server

EXPOSE 3306

LABEL version="1.0"
LABEL description="MariaDB Server"

HEALTHCHECK --start-period=5m \
  CMD mariadb -e 'SELECT @@datadir;' || exit 1

CMD ["mysqld"]

Using the command

docker run --name=db -p 3306:3306 -d db

The container starts, and exits after 1-2 seconds. Logs arent that helpful either, they only contain the line

[Note] mysqld (mysqld 10.3.34-MariaDB-0ubuntu0.20.04.1) starting as process 8 ...

I´ve managed to keep it running with an entry point I added, but executing "mysqld" there, doesnt make any difference.

docker run --interactive --tty --entrypoint /bin/sh db

Of course I also reinstalled docker a couple times already. A colleague of mine had no problems at all and it just worked instantly on his machine. Both of us use a Macbook with Intel chip.

Please let me know, if you have any clue to what the problem could be.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source