I have been working on a Docker file for the past couple days and when I go to start it, it will work if I don’t specify a location but when I specify a location it dose not copy anything it needs to that location. here is my docker file
FROM ubuntu:jammy
WORKDIR /usr/local/spacebar-server
RUN apt-get update && apt-get upgrade -y && apt-get install curl -y
RUN cd ~ && curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh && bash /tmp/nodesource_setup.sh && apt-get install nodejs
COPY ./spacebar /usr/local/spacebar-server
RUN apt-get install software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa
RUN apt-get install build-essential git python-is-python3 -y
RUN npm install -g npm
RUN npm i
RUN npm run setup
CMD npm run start
Back when I made Docker files I never had a workdir so I tried to remove it but that didn’t work since npm install needs a workdir. This is the error I get from docker when I start it
2023-04-08 09:23:40 npm ERR! code ENOENT
2023-04-08 09:23:40 npm ERR! syscall open
2023-04-08 09:23:40 npm ERR! path /usr/local/spacebar-server/package.json
2023-04-08 09:23:40 npm ERR! errno -2
2023-04-08 09:23:40 npm ERR! enoent ENOENT: no such file or directory, open '/usr/local/spacebar-server/package.json'
2023-04-08 09:23:40 npm ERR! enoent This is related to npm not being able to find a file.
2023-04-08 09:23:40 npm ERR! enoent
2023-04-08 09:23:40
2023-04-08 09:23:40 npm ERR! A complete log of this run can be found in:
I have tried docker compose but it has the same outcome. any ideas why its doing that?
I have tried to remove the workdir but that didn’t work I can’t think of anything else I can do
2
Answers
it’s possible that the COPY command is not copying the spacebar directory to the correct location when you specify a location. Try adding the following to make sure
spacebar
directory is copied to the correct location inside the container.Are you running Docker in WSL? If so, try updating to WSL app v. 1.2.1 or higher (NOTE: This does NOT mean you are downgrading to WSL1; the app and the arch are different).
See:
https://github.com/microsoft/WSL/issues/9921