https://github.com/dockersamples/helloworld-demo-node
Example used to demonstrate docker init CLI for a simple Hello World Node Program
https://github.com/dockersamples/helloworld-demo-node
Last synced: 8 months ago
JSON representation
Example used to demonstrate docker init CLI for a simple Hello World Node Program
- Host: GitHub
- URL: https://github.com/dockersamples/helloworld-demo-node
- Owner: dockersamples
- License: apache-2.0
- Created: 2023-05-08T11:02:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-02T10:58:16.000Z (over 1 year ago)
- Last Synced: 2025-03-05T02:41:37.871Z (over 1 year ago)
- Language: Dockerfile
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 5
- Forks: 35
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# A Simple Hello World Node Demo
Example used to demonstrate ```docker init``` CLI for a simple Hello World Node Program
## Run the application
You can simply use `node app.js` command.
This script creates a simple HTTP server that listens on port 8080 and returns a response with the message "Hello from Docker!" when accessed. You can save this script as app.js in your project directory and then run it using the command node app.js from the terminal.
Those commands will start a http server listening on port `8080`
and if your request `http://localhost:8080` you'll see the following output:
```shell
❯ curl http://localhost:8080
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
```
## Using Docker init
### Run the following command:
```bash
docker init
```
This utility will walk you through creating the following files with sensible defaults for your project:
- .dockerignore
- Dockerfile
- docker-compose.yaml
## Install the Dependencies
```
npm install
```
## Running the container service
```
docker compose up -d --build
```
## Accessing the Node app
```
curl localhost:8080
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
{ / ===-
\______ O __/
\ \ __/
\____\_______/
Hello from Docker!
```