- just because you can
sudo su
yum update
yum intsall git
yum install docker
systemctl status docker
systemctl enable docker
systemctl start docker
In this we have created a simple Express app that can take the user input of firstname and lastname and display the output
git clone https://github.com/InspiredEnigma12477/nodeapp.git
cd nodeapp
Note : Name the file as Dockerfile
FROM node:7
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD node server.js
EXPOSE 6969
Note : Possible errors
- you have created the file inside the
src
, it should be at root directory- given unwanted spaces
- Dockerfile name is case-sensitive
- node:7 not working use node:latest
- look for silly mistakes like spelling, cases !! 😅
In this we use build alias to build the image and -t
to give an alias or nametag to the image
docker build -t nodeapp .
docker images
In this we run the images mentioned with the
- external Port 8000
- internal port 6969
- -d for Run container in background and print container ID
- -p for Publishing a container's port(s) to the host
docker run -d -p 8000:6969 nodeapp
docker ps
docker kill hashcode
docker rmi <name_image OR hashcode> -f
Thank you