- Download Docker - arm64
- Download Docker - amd64
- Follow the instructions to install
Docker Desktop App
if you need help
Join the Discord - Fnbubbles420 Org Community
- a. Create a Folder for Your Project:
Open your terminal or command prompt and create a directory:
mkdir docker-simple-app cd docker-simple-app
b. Create app.js
: Inside the docker-simple-app folder, create the app.js
file. This will be your Node.js web server.
app.js
content:
// app.js
const express = require('express');
const app = express();
const port = 9090;
app.get('/', (req, res) => {
res.send('Hello, World! from bubblesthedev');
});
app.listen(port, () => {
console.log(`App listening on port ${port}`);
});
c. Create package.json
: Inside the same folder, create a package.json
file. This will describe your app and its dependencies.
package.json
content:
{
"name": "docker-simple-app",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "docker-simple-app",
"version": "1.0.0"
}
},
"description": "## Download and install `Docker` - **[Download Docker- arm64](https://desktop.docker.com/win/main/arm64/Docker%20Desktop%20Installer.exe?utm_source=docker&utm_medium=webreferral&utm_campaign=dd-smartbutton&utm_location=module)** - **[Download_Docker- amd64](https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe?utm_source=docker&utm_medium=webreferral&utm_campaign=dd-smartbutton&utm_location=module)** - **Follow the Instruction to install `Docker Desktop App` if you need help** ### Join the Discord - [Fnbubbles420 Org Community](https://www.discord.fnbubbles420.org/invite)",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "bubblesthedev",
"license": "ISC",
"dependencies": {
"express": "^4.21.1"
}
}
Inside the docker-simple-app
folder, create a file named `Dockerfile``. This file tells Docker how to build the image.
Dockerfile
content:
# Use the official Node.js LTS image based on Alpine
FROM node:lts-alpine
# Update apk and explicitly install OpenSSL
RUN apk update && apk add --no-cache openssl
# Set working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json and install dependencies
COPY package.json package-lock.json ./
RUN npm install --production
# Copy the rest of the application files
COPY . .
# Expose the app port
EXPOSE 9090
# Command to start the app
CMD ["npm", "start"]
After creating your project files, open your terminal or command prompt in the docker-simple-app
folder and run the following command to build the Docker image:
docker build -t simple-node-app .
-t simple-node-app
: This tags the image with the namesimple-node-app
..
: This tells Docker to use the Dockerfile in the current directory.
Once the image is built, you can run the container using:
docker run -p 9090:9090 simple-node-app
-p 9090:9090
: This maps port 9090 on your local machine to port 9090 in the Docker container.
Open your browser and go to:
http://localhost:9090
- You should see the message:
Hello, World! from bubblesthedev
To stop the running container, press CTRL + C
in the terminal where the container is running.
docker ps -a
docker stop <container_id_or_name>
- Then run this command again to check:
docker ps -a