I want to build mysql container which can use systemctl command then I build dockerfile with ubuntu and then install mysql.
But when I run container, it’s always exited
this is my Dockerfile
FROM ubuntu:18.04
RUN apt update && apt install vim rsyslog net-tools mariadb-server -y
The problem is that, docker will exit a container when the entrypoint/cmd command is done running.
and since “systemctl restart mariadb” will exit after it starts mariadb, it will exit the container.
So you need something that will never quit, and as @tekki mentioned, running mariadb in foreground will solve this