Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.83k stars 325 forks source link

Running in Docker Desktop doesn't persist data at /data #1791

Open RobbieLD opened 1 year ago

RobbieLD commented 1 year ago

Which service(blob, file, queue, table) does this issue concern?

blob, files, queue, table

Which version of the Azurite was used?

3.21.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub

What's the Node.js version?

14.17

What problem was encountered?

When mounting a volume to persist blobs across container restarts they blobs and not persisted.

Steps to reproduce the issue?

  1. Start a docker container with Azurite on the latest build and mount a volume to /data (as per the docs)
  2. Upload a blob
  3. Restart the container
  4. Observe that the blob is no longer there

Have you found a mitigation/solution?

Yes, to fix this you need to map /opt/azurite/<path> and use the -l <path> option on start up. This is because the app is storing the data in the home directory of the app rather than in '/data'. An example of a working docker compose file is given for completeness

version: '3.1'

services:
  azurite:
    image: mcr.microsoft.com/azure-storage/azurite
    container_name: azurite
    restart: always
    entrypoint: ["azurite", "--blobHost", "0.0.0.0", "--blobPort", "10000","-l", "data"]
    environment:
      AZURITE_ACCOUNTS: "dev:MTIzNDU2Nzg5"
    volumes:
      - "C:/temp/azureite:/opt/azurite/data"
    ports:
      - 10000:10000
blueww commented 1 year ago

@RobbieLD

Thanks for raising this issue! It looks you have already resolved it by change the docker-compose.yml file.

Do you mind to file a PR to update the sample file in Azurite Readme to fix this issue: https://github.com/Azure/Azurite#docker-compose

RobbieLD commented 1 year ago

Hi @blueww,

Yeah no worries. I've submitted a PR. I updated the docker cli examples and the docker compose example. PR 1793