Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

martinszeltins's avatar

What is the proper way to persist storage on production using Docker?

I have 2 Docker containers - 1) for Nginx and 2) for PHP server. When I upload a file using Laravel, the file is not on the PHP server container but not on Nginx container.

So far, I was able to solve this problem by creating a volume and sharing that volume for both containers. But is this the best way to do it? Does it have any performance downsides?

P.S. I don't want to use something like S3 for storage right now.

Here are my containers:

# Nginx server for the server side app
app-nginx-server:
  container_name: app-nginx-server
  build:
      dockerfile: ./docker/nginx-server/Dockerfile-production
  volumes:
    - ./server/storage:/var/www/storage
  ports:
    - 41166:80
  networks:
    - app-network


# PHP server for the server side app
app-php-server:
  build:
    dockerfile: ./docker/php-server/Dockerfile-production
  container_name: app-php-server
  restart: always
  volumes:
    - ./server/storage:/var/www/storage
  networks:
    - app-network
0 likes
0 replies

Please or to participate in this conversation.