0

I'm working on a Windows laptop and running Docker for Windows on it. I want to run an Ubuntu container with a specific version and a MySQL server on it. So the question is, do I have to download MySQL on the Ubuntu container or can I run 2 containers (Ubuntu and MySQL) and combine them? How do I combine these 2 containers?

1 Answer 1

2

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.

5
  • Thanks Mike this is really helpful. Actually you answered 2 things for me . So when i want a Debian container with mysql apache freeradius etc in it( with network config and so on) i do it with docker compose right? Commented Aug 20, 2020 at 7:18
  • @user19215 docker-compose is not required, but just a helpful way to run containers. You could instead do the same using docker commands, but docker-compose is much easier to configure (the docker-compose.yml is YAML syntax). Commented Aug 20, 2020 at 14:42
  • @user19215 So if you want multiple services in one container not in different ones that are connected via a network then you will have to create your own Docker image. This is pretty simple to do if you just want basic non production ready images. Commented Aug 21, 2020 at 2:24
  • @user19215 Here's official documentation on running multiple services in a single container: docs.docker.com/config/containers/multi-service_container Commented Aug 26, 2020 at 12:11
  • @user19215 That being said it's not recommended as Docker containers are meant to be application containers, that is there should be a single service running in a single container. It sounds like what you want are OS containers like LXC: linuxcontainers.org Commented Aug 26, 2020 at 12:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.