When dealing with a virtual environment, VirtualBox d's virtual machine uses a hypervisor on the host machine to run guest os and then middleware, but in the case of Docker, a container is used. .. The container uses the kernel of the host machine and isolates processes, users, etc., so that it can be operated as if another machine is running. Therefore, it is lightweight and can be moved at high speed. However, of course, even if you go to the virtual environment, you have to divide the capacity from your own PC, so make sure you have enough free space. (Excerpt from Reference Article 1)
MySQL is a relational database developed by Oracle. (Relational type is simply a format like excel) Basic operations are performed using the programming language, SQL. A feature of MySQL is that it supports various UNIX-based operating systems and various platforms such as Windows, and also has abundant programming languages that can be accessed. It's simple, fast, and works well with PHP. If you want to know more about database types, this article is easy to understand. What is a database? We will explain the types, features, and benefits in detail!
Introduced ubuntu as a virtual environment By the way, the image contains the packages necessary to handle the container, and this time Ubuntu and MySQL correspond to it. A container is an environment that can be executed using that image.
#Introducing ubuntu image to Docker
$ docker pull ubuntu:16.04
#Run Ubuntu and log in to the shell
$ docker run -it ubuntu:16.04
Install python and mysql-server (mysql-server instead of mysqld)
$ apt-get update
$ apt-get install -y python3 python3-pip
$ apt-get install -y mysql-server
Install mysqlclient to connect to MySQL with Python
$ apt-get install -y libmysqlclient-dev
$ pip3 install mysqlclient
Save this container as ubuntu-mysql
$ docker ps -a
$ docker commit (Container ID) ubuntu-mysql
Execute while mounting the folder containing the file you want to execute locally.
$ docker run -it -v <The path of the folder you want to mount locally>:<Path in virtual environment> ubuntu-mysql /bin/bash
[Reference article]
[Related article] Errors that tend to occur when downloading MySQL to Ubuntu 16.04