I am running into a frustrating problem when trying to create and run a new docker container. When I upload my code to a Github repository and then use Docker Hub to build it, the build completes without any errors. However, when I try to create and then run the new container on my own server I find that the necessary files and directories have not been copied into the new container or into the local directories that were bound to the container directories (obviously). Strangely though, it does seem that the init.sh
script referenced at the end of my Dockerfile is being copied because it runs, but it fails because the other files that were supposed to be copied into the WORKDIR
are not there. Iβve tried different files structures and COPY
commands to no avail, and all of the files and directories to be copied are in the root of the repository at the moment. Here is my current Dockerfile:
FROM node:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/
RUN \
npm install -g @adonisjs/cli && \
npm install
COPY . /usr/src/app/
VOLUME /usr/src/app
RUN \
cp /usr/src/app/init.sh /usr/local/bin/ && \
chmod 755 /usr/local/bin/init.sh && \
ln -s usr/local/bin/init.sh / # backwards compat
EXPOSE 8080
CMD ["/init.sh"]
And my docker create and docker run commands:
docker create --name='ferdi-server' -p '3333:80' -v '/mnt/cache/appdata/ferdi-server':'/usr/src/app' 'xthursdayx/ferdi-server-docker'
docker run -d --name='ferdi-server' -p '3333:80' -v '/mnt/cache/appdata/ferdi-server':'/usr/src/app' 'xthursdayx/ferdi-server-docker'
Any ideas? Iβve been trying to figure this out for two days and am at a dead end.
FYI here are the file structures and COPY commands Iβve most recently tried
βββ Dockerfile
βββ init.sh
β βββ api
β βββ package.json
β βββ package-lock.json
β βββ .env.example
β βββ etc
β βββ init.sh
β βββ app
β | βββ directory
β βββ config
β βββ app.js
β βββ etc.js
with command COPY api/ /usr/src/app/
and
βββ Dockerfile
βββ init.sh
βββ package.json
βββ package-lock.json
βββ .env.example
βββ etc
βββ init.sh
β βββ app
β βββ directory2
β βββ config
β βββ app.js
β βββ etc.js
with command COPY . /usr/src/app/