Dockerize Travel-Website

Dockerize Travel-Website

Clone the code to your local repo

sudo apt update
mkdir project-01
git clone https://github.com/frontendzone/travel-website.git

Create Dockerfile

# Use the official Node.js image as the base image
FROM node:latest

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Update the machine
RUN apt install

# Install the dependencies
RUN npm -y install

# Copy the rest of the application code to the working directory
COPY . .

# Expose a port (e.g., 3000) on which the application will listen
EXPOSE 3000

# Specify the command to run the application
CMD ["npm", "start"]

Building an Image

sudo docker build -t myimage .

Create a container and run this image

sudo docer run -itd -p 3000:3000 myimage

Finally, test the Output

Now it's showing on our IP

Thank you

Reach me via below link

LinkedIn