Skip to main content
Clairfied and expanded the answer to better respond to the question.
Source Link

At first, I misread your question, thinking you wanted to run more than one service together, so I had recommended Docker Compose which makes it easy to run multiple services together, with networking. You, and can even specify the start up order.

But now I see you are just trying to run MySQL, and wondering do you need separate containers for the OS and MySQL: in short, no you don't need two containers. Instead, just get the MySQL image from DockerHub at https://hub.docker.com/_/mysql?tab=description

The reason you can just use that MySQL Docker image by itself is because it already is installed on a Debian image, which you can see in the Dockerfile at https://github.com/docker-library/mysql/blob/master/8.0/Dockerfile where it shows:

FROM debian:buster-slim 

So, to solve the problem, do:

  1. docker pull mysql
  2. docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag as mentioned in the instructions on the Docker Hub page. Additional documentation at https://github.com/docker-library/docs/tree/master/mysql

I do strongly recommend using Docker Compose (docker-compose command) to run containers, as it makes it easier to organise and run them.

Docker Compose makes it easy to run multiple services together, with networking. You can even specify the start up order.

At first, I misread your question, thinking you wanted to run more than one service together, so I had recommended Docker Compose which makes it easy to run multiple services together, with networking, and can even specify the start up order.

But now I see you are just trying to run MySQL, and wondering do you need separate containers for the OS and MySQL: in short, no you don't need two containers. Instead, just get the MySQL image from DockerHub at https://hub.docker.com/_/mysql?tab=description

The reason you can just use that MySQL Docker image by itself is because it already is installed on a Debian image, which you can see in the Dockerfile at https://github.com/docker-library/mysql/blob/master/8.0/Dockerfile where it shows:

FROM debian:buster-slim 

So, to solve the problem, do:

  1. docker pull mysql
  2. docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag as mentioned in the instructions on the Docker Hub page. Additional documentation at https://github.com/docker-library/docs/tree/master/mysql

I do strongly recommend using Docker Compose (docker-compose command) to run containers, as it makes it easier to organise and run them.

Source Link

Docker Compose makes it easy to run multiple services together, with networking. You can even specify the start up order.