Home  >  Article  >  Operation and Maintenance  >  How to make the project run when there is only a linux system

How to make the project run when there is only a linux system

WBOY
WBOYforward
2023-05-23 21:34:04794browse

1. Create a project

How to make the project run when there is only a linux system

Please click here to exit full-screen mode:

How to make the project run when there is only a linux system

2. Write the dockerfile

"Dockerfile
FROM php:5.6-apache
RUN docker-php-ext-install mysqli
ADD project1 /var/www/html
"

After editing the dockerfile, generate the image. The command is: docker build -t malina_php_project .

##When you see


How to make the project run when there is only a linux system

Indicates that the image has been generated successfully

3. Generate a container and run the image

"
docker run -it -d    --name malina_php_project malina_php_project
"
rrree

How to make the project run when there is only a linux system

4 , Run the file in the container

进行查看镜像是否处于活动状态
docker ps

How to make the project run when there is only a linux system

在浏览器输入localhost,发现这什么鬼,也不报错也不显示,可以docker logs (容器id)18b429b2ceac
看见ip了

How to make the project run when there is only a linux system##5. What files were added

再次在浏览器输入访问:http://x.x.0.2/phpinfo.php,访问到了开心不,激动不

ADD project1 /var/www/html
将项目copy到容器的var/www/html目录下,这里只会把project1下面的内容,project1本身目录不复制
How to make the project run when there is only a linux system

How to make the project run when there is only a linux system6. Directory mounting

docker exec -it 18b429b2ceac(容器id) /bin/bash

The above is the detailed content of How to make the project run when there is only a linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete