Search code examples
dockerdockerfiledocker-volume

Can't run my docker image with a mounted volume


I created a Volume using Docker Desktop, called Downloads. I bind it successfully with a ftp, i can add/remove files and i can see it in the Data tab about the downloads volume.

I have a home made api that i want it to access the downloads volume but when i run it, the container just displays the node version.

v17.9.1

The dockerfile :

FROM node:17

WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install --quiet
COPY . .
VOLUME downloads /downloads
CMD [ "node", "main.js" ]

The build command :

docker build . -t myapi/myapidev

The command :

docker run -p 3001:3001 --name API -d myapi/myapidev -v downloads:/downloads

What do i do wrong ?


Solution

  • Try this

    docker run -p 3001:3001 --name API -d -v downloads:/downloads myapi/myapidev 
    

    Name of the image must be at the end of command.