2

i am trying write a Dockerfile like that

FROM debian:stable
RUN apt-get update
RUN apt-get install -y mariadb-server
EXPOSE 3306
CMD ["mysqld"]

I create the image with

docker build -t debian1 .

And i create the container with

docker run -d --name my_container_debian -i -t debian1

20 seconds after, docker ps -a tells that container is exited. Why? I want the container is up and mariadb running. Thanks. Sorry for the question.

1
  • Does mysqld run in foreground or background? It should be executed in foreground, otherwise, the container will just be ended. Commented Dec 31, 2017 at 19:30

1 Answer 1

2

mysqld alone would exit too soon.

If you look at a MySQL server Dockerfile, you will note its ENTRYPOINT is a script docker-entrypoint.sh which will exec mysqld in foreground.

exec "$@"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.