How can I make the actual image files persistent during the file upload process with docker?

I recently developed a docker-compose application in PHP including the file upload process.

However, the actual uploaded files to the server would be lost when exiting the container.

How did you deal with this issue? Please tell me how to make the files permanent.

For example:

  • Using an external server like S3 to store files.
  • Using Docker storage features for volumes.
+3


source to share


1 answer


This can be done using docker compose. You will be able to access the files inside the container by installing them in the host's external directory. The files uploaded to Wordpress are stored in wp-content/uploads

and you can mount them using this file to create a sample docker:

version: '3'
services:
  mysql-database:
    image: mysql
    container_name: mysql-database
    volumes:
      - ./mysql/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d
    ports:
      - 3306:3306

  wordpress-sites:
    image: wordpress:custom
    build:
      context: ./wordpress
      dockerfile: wordpress.dockerfile
    container_name: wordpress-sites
    links:
      - mysql-database
    depends_on:
      - mysql-database
    ports:
      - 8080:80
    volumes:
      - ./wordpress/wp-content:/var/www/html/wp-content

      



The volume documentation should help you.

0


source







All Articles