How to migrate applications to docker

angryTom
Release: 2020-03-16 17:05:39
Original
2649 people have browsed it

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
Copy after login

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
Copy after login

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 #导入
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!