For creating docker image, we need Dockerfile
The name should be Dockerfile
Inside Dockerfile,
- FROM --> from what image you are using i.e. node:20
- WORKDIR --> create a work directory i.e. /calculator-app
- COPY --> copy local files into image i.e. COPY server.js .
- EXPOSE --> tell the developer, in which port the service is running i.e. EXPOSE 5000
- CMD --> execute the command i.e. CMD ["node","server.js"]
docker build -t image-name .This will build the docker image
Running the image will run on a container which is created on the execution of the image
docker run -p 9002:5000 --name=container-name image-name
docker run -p 9002:5000 --name=calci-v1 calculator It will run the image in http://localhost:9002
docker volume create <volume-name>
docker volume create calci-voldocker run -p 9002:5000 -v volume-name:/folder-name --name=whatever-name-you-want folder-name
docker run -p 9002:5000 -v calci-vol:/calci-storage --name=calci-v1 calculator docker <things> ls # things refers to image, container,cvolume etcBInd mount is a concept of mounting the local storage to a Container
docker run -p 9002:5000 -v path\to\local_vault:/calci-storage --name=calci-v1 calculator For any reference, watch this detailed video: https://youtu.be/i8vnIi08UxQ