How can I make actual image files persistent in file upload process running with docker?

Recently I have developed an application running with docker in PHP including file upload process.

However, actual uploaded files to the server would have been lost when the container exits.

  • How do i wait for a db container to be up before my spring-boot app starts
  • Hostname for website running inside Docker
  • docker, --storage-opts and aufs storage-driver
  • install additional python package on docker
  • Could not find rake-11.1.2 in rails docker container
  • Access binaries inside docker
  • How did you deal with the matter?
    Please tell me how to make files persistent.

    For example:

    • Using external server like S3 for storing files.
    • Utilizing Docker storage functions for volumes.

  • Gitlab-runner with syntax error
  • Use docker-compose with multiple repositories
  • Automatically Start Services in Docker Container
  • How to access a Tensorflow docker instance from the “outside” without Jupyter - for distributed Tensorflow
  • Docker in IntelliJ IDEA for Mac not working
  • Docker (under boot2docker) does not look for/find local images when building
  • One Solution collect form web for “How can I make actual image files persistent in file upload process running with docker?”

    This can be done using docker compose. You will be able to access the files inside container by mounting them to external host directory. The files uploaded to wordpress are stored in wp-content/uploads and you can mount this using this sample docker-compose file:

    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 documentation regarding volumes should be able to help you.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.