Site icon i2tutorials

Docker – File Instructions

Docker File Instructions

 

Dockerfile is a script that contains instructions for building a Docker image. Here are some common instructions used in Dockerfile:

Here is an example Dockerfile that uses some of these instructions:

# Use the official Node.js image as the base image 
FROM node:14 
# Set the working directory to /app 
WORKDIR /app 
# Copy the package.json and package-lock.json files to the container 
COPY package*.json ./ 
# Install the dependencies 
RUN npm install 
# Copy the rest of the application files to the container 
COPY . . 
# Expose port 3000 
EXPOSE 3000 
# Start the application when the container starts CMD 
[ "npm", "start" ] 

Dockerfile uses Node.js as the base image, sets working directory to /app, copies package.json, package-lock.json, installs the dependencies, copies the rest of the application files, exposes port 3000, and starts the application when the container starts.

 

Exit mobile version