简体   繁体   English

nginx 容器正在从主机运行 php

[英]nginx container is running php from host

I have two containers PHP and nginx linked between them and i want that nginx container run PHP from php container. I have two containers PHP and nginx linked between them and i want that nginx container run PHP from php container. Now it's running PHP from my host machine.现在它正在我的主机上运行 PHP。 How can i fix that.我该如何解决。 Bellow is my docker-compose.yml file:波纹管是我的docker-compose.yml文件:

 > version: '3' > services: > nginx: > image: nginx:alpine > volumes: > -./app:/app > -./nginx-config/:/etc/nginx/conf.d/ > ports: > - 80:80 > depends_on: > - php > php: > image: php:7.3-fpm-alpine > volumes: > -./app:/app

You can look into dockerize-nginx-php docker-compose file, it supports both build time code for php and nginx and also support run code from mounting host volumes.您可以查看dockerize-nginx-php docker-compose 文件,它支持phpnginx的构建时间代码,还支持安装主机卷的运行代码。

git clone https://github.com/Adiii717/dockerize-nginx-php.git
cd dockerize-nginx-php;
docker-compose -f docker-compose-buildtime.yml build
docker-compose -f docker-compose-buildtime.yml up

docker-compose.yml docker-compose.yml

version: '3'
services:
  nginx:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    image: nginxbuild_time
    ports:
      - 80:80
    depends_on:
      - php
  php:
    build:
      context: .
      dockerfile: Dockerfile.php
    image: php

dockerfile.php dockerfile.php

FROM php:7.3-fpm-alpine
WORKDIR /app
COPY app /app

Dockerfile.nginx Dockerfile.nginx

FROM nginx
COPY nginx-config /etc/nginx/conf.d/
COPY app /app
 

So @Ahmed resolves the issue by installing composer within container.所以@Ahmed 通过在容器中安装作曲家解决了这个问题。

The problem is to install composer under php container.问题是在 php 容器下安装 composer。 So i added a command to install composer in the DockerFile of PHP.所以我添加了一个命令来在 PHP 的 DockerFile 中安装作曲家。 Thanks for your support!谢谢你的支持!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM