yiisoft / yii2-docker

Official Docker images suitable for Yii 2.0
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
384 stars 202 forks source link

Imagine\Exception\RuntimeException Unable to open image /tmp/ on nginx, php-fpm in docker #103

Closed 3579km closed 3 years ago

3579km commented 3 years ago

Hello,

Can't upload image because of an error. I am using nginx official image and php-fpm own version image (based on official php-fpm + added extensions). Looks like /tmp directory is not visible. After that issue, I tried chom 777 to tmp and share /tmp folder to nginx and php both containers but it doesn't take an effect. Using Openserver uploading is OK.

docker-compose file

version: "3"

services:
  nginx:
    container_name: nginx
    restart: unless-stopped
    image: nginx:${NGINX_VERSION}
    ports:
      - ${HTTP_PORT}:80
      - ${HTTPS_PORT}:443
    volumes:
      - ${NGINX_CONFIGS}:/etc/nginx/conf.d/
      - ${PROJECTS_DIRECTORY}:/usr/share/nginx/html/
      - ./data/logs/nginx:/var/log/nginx
      - ./data/nginx/tmp:/tmp
    depends_on: 
      - php

  php:
    container_name: php
    restart: unless-stopped
    image: ${PHP_IMAGE}:latest
    ports:
      - 9000:9000
    volumes:
      - ${PROJECTS_DIRECTORY}:/usr/share/nginx/html/
      - ./config/php_ini/php.ini:/usr/local/etc/php/conf.d/php.ini
      - ./data/nginx/tmp:/tmp

  mysql:
    container_name: mysql
    restart: unless-stopped
    image: mysql:${MYSQL_VERSION}
    volumes:
       - ./data/mysql:/var/lib/mysql
    command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci --bind-address=0.0.0.0  --sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    environment:
      - MYSQL_ROOT_PASSWORD=root
    ports:
      - ${MYSQL_PORT}:3306

  phpmyadmin:
    container_name: phpmyadmin
    restart: unless-stopped
    image: phpmyadmin/phpmyadmin:latest
    environment:
      - PMA_HOST=mysql
      - UPLOAD_LIMIT=256M
    ports:
      - ${PMA_PORT}:80

  rabbitmq:
    container_name: rabbitmq
    restart: unless-stopped
    image: rabbitmq:management
    volumes:
       - ./data/rabbitmq:/data
    ports:
      - 5672:5672
      - 15672:15672
schmunk42 commented 3 years ago

This is not really an issue with the image, since it's a custom setup. In fact, running php-fpm + nginx in separate containers is always a bit tricky. See also https://github.com/yiisoft/yii2-docker/issues/12

Or is there something you'd change?