dongsibao8977 2017-06-27 03:25
浏览 39

如何使用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 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.
  • 写回答

1条回答 默认 最新

  • dousou2897 2017-06-27 03:35
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集