Search code examples
dockerraspberry-piraspbiancdn

Raspbian - best docker image to store static content


I am developing a simple web page to manage inventory and am currently using docker for:

  • Container with a tomcat server to host the web page
  • Container with a MySQL instance to store inventory data. This data is then accessed from the web page application running in the tomcat container.

Both containers are running under Raspbian OS in a Raspberry Pi (model 1).

I was considering configuring another docker container to act as a CDN for storing static content such as CSS files or pictures. These pictures can be uploaded from the web page so that the web page can access them later.

Do you recommend this approach of having a container to manage just static content? If so, which docker image do you recommend to achieve this? I am not interested in storing this static content outside my Raspberry Pi.

Thanks in advance.


Solution

  • Since you are:

    not interested in storing this static content outside my Raspberry Pi

    There is not reason to use another container for that. A simple Volume does the job.

    https://docs.docker.com/storage/volumes/

    update due to this comment

    But if I use a volume, how can I access a given file using a HTTP URL?

    In this case simple webserver like nginx or apache will do. Simply mount a volume into the webroot and configure the server to your needs, map a port and that should be it.

    So the answer to the question should be: A webserver like nginx or apache.

    For example with nginx:

    docker run \
      --name static \
      -v /var/www/static:/usr/share/nginx/html:ro \
      -p 8888:80 \
      -d \
      nginx
    

    https://hub.docker.com/_/nginx/