Home  >  Article  >  Operation and Maintenance  >  How to migrate applications to docker

How to migrate applications to docker

angryTom
angryTomOriginal
2020-03-16 17:05:392690browse

How to migrate applications to docker? This article will take the PHP web program as an example to explain how to migrate the application to run on docker. Hope this helps you!

How to migrate applications to docker

How to migrate applications to docker

The steps to migrate applications to docker are as follows:

Step one: Pull the image.

docker pull tutum/lamp

Step 2: Run the container.

In this experiment, the local application root directory is /home/wwwroot/default, please modify the path according to your own situation. YOURPASSWORD maintains the previous database password.

docker run -d -p 81:80 -p 3307:3306 -e MYSQL_PASS="YOURPASSWORD" -v /home/wwwroot/default:/app tutum/lamp

Step 3:Modify the application database configuration file.

In this image, the root user is not allowed to connect outside the container - you should use the admin user!

Just modify the database user name in the configuration file of the PHP application.

Step 4: Export the local database data, and then import the database in the container.

It’s too simple, just export and import from the mysql command line.

MySQLdump -h localhost -u root -p mydb >e:\MySQL\mydb.sql #导出
MySQLdump -h localhost -u root -p mydb mytable>e:\MySQL\mytable.sql #导入

Through the above 4 steps, you can migrate the application to run on docker.

Recommended learning: MySQL video tutorial

The above is the detailed content of How to migrate applications to docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to force close dockerNext article:How to force close docker