To create a docker image, the following steps need to be followed -
i) Create a Dockerfile.
ii) Add instructions to this Dockerfile -
A sample Dockerfile is added here for your reference -
FROM node WORKDIR /app COPY package.json RUN npm install COPY . . EXPOSE 3000 CMD ["node","app.js"]
iii) Run the following command to build an image based on the Dockerfile -
docker build .
iv) To run the built image -
docker run <image_id>
v) To list all running instances of the image i.e. containers -
docker ps