skip to Main Content

I’m quite new to Docker and this question might seem trivial but there it is.

So I’ve dockerized a brand new React Native app (As a proof of concept) on my Computer A, and the container works fine but after taking out the container onto my Computer B (I transform it into a .tar.gz file then load and run the image) I have this error :
Error no such file or directory

It works on Computer A with the react project being in the same folder as the Dockerfile, but when I launch the container on Computer B it tells me that it can’t find the app folder even when imported on the computer

Feel free to ask any question since I know my explanations can be troubled.

Edit to Answer larsks :

A : I get my .tar.gz file with docker save app | gzip -> testApp.tar.gz

B :I then transfer my container with scp testApp.tar.gz second@computer

C : I run the image with docker load < testApp.tar.gz then docker run app

D : The exact output is

npm ERR! syscall open
npm ERR! path /app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

Edit2 :

Dockerfile :

FROM arm64v8/node:14
COPY qemu-aarch64-static /usr/bin

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /app

CMD ["npm", "start"]

docker-compose.yml

version: "3.3"

services:
  app:
    image: app:latest
    build: .
    ports:
      - 19000:19000
      - 19001:19001
      - 19002:19002
      - 19006:19006
    environment:
      - NODE_ENV=dev
      - EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0
      - REACT_NATIVE_PACKAGER_HOSTNAME=0.0.0.0
    volumes:
      - ./app:/app/

The app is simply the app from the base project of React native
npx create-expo-app app

2

Answers


  1. Chosen as BEST ANSWER

    The problem was that I didn't use ADD in my dockerfile so the container didn't included my app file.

    Add this to Dockerfile :

    ADD /app ./
    

  2. What’s the Dockerfile contents? From first look seems that the folder you navigating ‘/app/package.json’ doesn’t exist and npm command executed inside container couldn’t find that file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search