0

I have Node.js app which is using Sequelize ORM for working with SQLite DB and umzug library for migrations. App is containerized with Docker.

When I run my container like:

docker run -v /home/user/data:/app/data image:tag

everything is working fine, but when I want to use named volume:

docker volume create appdata
docker run -v appdata:/app/data image:tag

I'm getting this error:

DatabaseError [SequelizeDatabaseError]: SQLITE_ERROR: duplicate column name: isPublic

Here is my Dockerfile:

FROM node:14-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

# Install client dependencies
RUN mkdir -p ./public ./data \
    && cd client \
    && npm install \
    && npm rebuild node-sass

# Build 
RUN npm run build \
    && mv ./client/build/* ./public

# Clean up src files
RUN rm -rf src/ ./client \
    && npm prune --production

EXPOSE 5000

ENV NODE_ENV=production

CMD ["node", "build/server.js"]

Any ideas what might be the reason? Something with permissions maybe?

Paul Ulibro
  • 315
  • 2
  • 6
  • 12
  • In the first example, is `/home/user` the directory containing your application source; if you have a `/home/user/data/foo.sqlite` file, does the `COPY . .` line insert it into the image (or does it get `.dockerignore`d)? You also might compare `docker run --rm ... image:tag ls -l /app/data` with the two `-v` options to see what exists in the container before migrations start. – David Maze Nov 22 '21 at 12:05
  • No, `/home/user/data` is empty directory where content from container `/app/data` is mounted. Data directory (if present) is also ignored during image building. – Paul Ulibro Nov 22 '21 at 18:53

0 Answers0