I face this exact error but Idk how to solve it. Idk if my windows firewall is blocking it & if it is, then how would i solve it. for context, i'm not using docker desktop. just docker with wsl2 on windows 11.
I'm dockerizing a remix app in node.js.
docker-compose.yml
version: "3.8"services: redis: image: redis:7.2.4-alpine container_name: aff_redis_dev env_file: - ../../.env.development restart: always ports: - 6379:6379 command: redis-server --save 60 1 --loglevel warning --requirepass 123456abc healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 30s retries: 50 volumes: - redis_data:/data web: image: affiliates:0.0.1 build: context: ../../ dockerfile: docker/development/Dockerfile container_name: aff_dev env_file: - ../../.env.development environment: - WATCHPACK_POLLING=true - CHOKIDAR_USEPOLLING=true ports: - 3001:3000 - 8002:8002 volumes: - ./:/app - ../../data:/data restart: unless-stopped depends_on: redis: condition: service_healthyvolumes: redis_data: driver: local
Dockerfile
FROM node:20-alpine AS base# mostly inspired from https://github.com/BretFisher/node-docker-good-defaults/blob/main/Dockerfile & https://github.com/remix-run/example-trellix/blob/main/Dockerfile# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.RUN apk add --no-cache libc6-compatRUN corepack enable && corepack prepare pnpm@8.15.4 --activate # set the store dir to a folder that is not in the projectRUN pnpm config set store-dir ~/.pnpm-storeRUN pnpm fetch# 1. Install all dependencies including dev dependenciesFROM base AS deps# Root user is implicit so you don't have to actually specify it. From https://stackoverflow.com/a/45553149/6141587# USER rootUSER node# WORKDIR now sets correct permissions if you set USER first so `USER node` has permissions on `/app` directoryWORKDIR /app# Install dependencies based on the preferred package managerCOPY --chown=node:node package.json pnpm-lock.yaml* ./COPY --chown=node:node /app/drizzle/migrations ./migrationsRUN pnpm install --frozen-lockfile --prefer-offline# 2. Start the development server# Inspired by https://github.com/vercel/next.js/discussions/36935RUN mkdir -p /app/.cache && chown -R node:node /app/.cache# Persist the remix cache in a volumeVOLUME ["/app/.cache"]# COPY --from=deps --chown=node:node /app/node_modules ./node_modulesCOPY --chown=node:node . .# This will do the trick, use the corresponding env file for each environment.COPY --chown=node:node .env.development .env.development# Copied from https://stackoverflow.com/a/69867550/6141587USER root# Give /data directory correct permissions otherwise WAL mode won't work. It means you can't have 2 users writing to the database at the same time without this line as *.sqlite-wal & *.sqlite-shm are automatically created & deleted when *.sqlite is busy.RUN mkdir -p /data && chown -R node:node /dataUSER nodeEXPOSE 3000ENV PORT 3000ENV HOSTNAME 0.0.0.0ENV NODE_ENV developmentCOPY --chown=node:node public ./public# Move the drizzle directory to the runtime imageCOPY --chown=node:node /app/drizzle/migrations ./migrationsCOPY --chown=node:node scripts/drizzle-migrate.mjs ./scripts/drizzle-migrate.mjsCOPY --chown=node:node scripts/package.json ./scripts/package.jsonCOPY --chown=node:node scripts/pnpm-lock.yaml ./scripts/pnpm-lock.yamlCOPY --chown=node:node scripts/run.dev.sh ./run.dev.shRUN chmod +x run.dev.shCMD ["sh", "run.dev.sh"]
run.dev.sh
#!/bin/bashset -e# Set the directory of the database in a variableDB_PATH=/data/affiliates.dev.sqlite# Set to true only when you want to run the migrate script, i.e, when changing database schema# Automate it by only setting it to true by tracking `entries.idx` in `migrations/meta/_journal.json`MIGRATE_DATABASE=false# Inspired by https://pranavmalvawala.com/run-script-only-on-first-start-up & https://serverfault.com/a/1134812/1078165FIRST_TIME_MIGRATION_DEV="FIRST_TIME_MIGRATION_DEV"if [[ ! -e /data/$FIRST_TIME_MIGRATION_DEV ]] || [[ $MIGRATE_DATABASE = true ]]; then # Place your script that you only want to run on first startup. echo 'Initialize database first time only' touch /data/$FIRST_TIME_MIGRATION_DEV echo "Migrating database '/data/affiliates.dev.sqlite'" pnpm db:migrate:dev & PID=$! # Wait for migration to finish wait $PIDfiecho "Starting development server..."pnpm dev
if i remove the volumes mapping - ./:/app
from docker-compose.yml
, then everything works fine.
but if i add it, i get this error:
sh: can't open 'run.dev.sh': No such file or directory
as said in the other answer, i tried this command:
docker run -it --rm -v "$(pwd):/app" busybox ls -l /app
i got this:
Unable to find image 'busybox:latest' locallylatest: Pulling from library/busybox7b2699543f22: Pull completeDigest: sha256:650fd573e056b679a5110a70aabeb01e26b76e545ec4b9c70a9523f2dfaf18c6Status: Downloaded newer image for busybox:latesttotal 293-rwxrwxrwx 1 1000 1000 1432 Mar 10 10:53 Makefile-rwxrwxrwx 1 1000 1000 13 Jan 21 06:43 README.mddrwxrwxrwx 1 1000 1000 512 Jan 24 05:42 appdrwxrwxrwx 1 1000 1000 512 Jan 25 16:23 builddrwxrwxrwx 1 1000 1000 512 Mar 10 09:30 datadrwxrwxrwx 1 1000 1000 512 Mar 9 13:11 docker-rwxrwxrwx 1 1000 1000 265 Jan 25 06:22 drizzle.config.ts-rwxrwxrwx 1 1000 1000 80 Mar 10 14:17 env.d.ts-rwxrwxrwx 1 1000 1000 324 Feb 28 07:21 litestream.ymldrwxrwxrwx 1 1000 1000 512 Mar 11 07:27 node_modules-rwxrwxrwx 1 1000 1000 2574 Mar 11 07:27 package.json-rwxrwxrwx 1 1000 1000 289002 Mar 11 07:27 pnpm-lock.yaml-rwxrwxrwx 1 1000 1000 80 Mar 11 07:26 postcss.config.mjs-rwxrwxrwx 1 1000 1000 247 Mar 10 10:36 prettier.config.cjsdrwxrwxrwx 1 1000 1000 512 Jan 25 16:23 public-rwxrwxrwx 1 1000 1000 156 Mar 10 11:56 remix.config.cjsdrwxrwxrwx 1 1000 1000 512 Mar 10 12:10 scripts-rwxrwxrwx 1 1000 1000 171 Jan 19 09:18 tailwind.config.ts-rwxrwxrwx 1 1000 1000 585 Mar 10 14:18 tsconfig.json-rwxrwxrwx 1 1000 1000 450 Mar 11 07:20 vite.config.ts
i understood that the error meant that it didn't find run.dev.sh
in the top-most directory on my host side but i don't know how to solve the error?
i tried $pwd
, $(pwd)
, $(PWD)
, ${PWD}
& many other variations. finally, settled on ./:/app
as it is the provided solution here that works cross-platform.
how do i solve this?
the reason i'm mapping the current directory is because i want hmr/live-reloading to work with remix.
but i have to use docker as i need redis which isn't directly available in windows. of course, i can just start a redis server but i'd like to use docker to control it all.