×

Html & Html5

The World's best Software Development Study Portal





Pull Docker Image
docker pull nginx
So lets this image nginx 1.23 as container

docker run nginx:1.23

Open new terminal
write-
docker ps

We should see one container we just run Run docker image in background without blocking terminals-:
docker run -d nginx:1.23
And check with
docker ps
docker logs f8c246a78222(container ID)
- [ ] docker run nginx:1.22-alpine(if image not available locally then it will go to docker hub then pull the image)
Expose the Ports
If we try to access the ports
localhost:80 (nothing is available)
To accès that container we needs to bind it
First we will stop it
docker stop container ID
Lets create new container and do the port binding
docker run -d -p 9000:80 nginx:1.23 (-d running in background mode detached mode)(-p 9000:80 this port expose to localhost)
http://localhost:9000/ (open It in browser )
——————————————————————
Start n stop containers
docker ps -a(this give u list of start n stop containers)
Docker start container id
Docker stop container id
reset command to clear terminal in Mac
Give name to container
docker run --name parveen -d -p 9000:80 nginx:1.23
docker logs parveen
Create our own docker image for application.
Create a server.js file inside src folder
——————————————
const express = require ("express")
const app = express();
const port = process.env.PORT || 3000
app.get("/",(req,res)=>{
res.send("Hello to ITC")
});
app.listen(port,()=>{
console.log(`Server is runung on port no ${port}`);
})
—————————————
Now create Dockerfile inside src
FROM node:19-alpine
COPY package.json /app/
COPY / /app/
WORKDIR /app
RUN npm install
CMD ["node", "server.js"]








CSS 3 training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute