Sobes.tech
Junior — Middle

Do you have practical experience using Docker for containerizing applications?

sobes.tech AI

Answer from AI

Yes, Docker is widely used for containerizing applications, including Node.js projects. Containerization allows packaging an application with all its dependencies into an isolated environment, making deployment and portability easier.

Example of a simple Dockerfile for a Node.js application:

# Use the official Node.js image
FROM node:18-alpine

# Create a working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy source code
COPY . .

# Expose port
EXPOSE 3000

# Run the application
CMD ["node", "index.js"]

With such a Dockerfile, you can build an image and run the application in a container, which guarantees the same environment across different machines.