https://github.com/yds12/minimal-containerized-webapp
A minimal Node.js/Express web-app prepared for building a Docker container.
https://github.com/yds12/minimal-containerized-webapp
docker docker-container docker-image node-js tutorial
Last synced: 11 months ago
JSON representation
A minimal Node.js/Express web-app prepared for building a Docker container.
- Host: GitHub
- URL: https://github.com/yds12/minimal-containerized-webapp
- Owner: yds12
- Created: 2020-05-03T10:24:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T16:16:46.000Z (about 3 years ago)
- Last Synced: 2025-01-13T15:29:42.312Z (about 1 year ago)
- Topics: docker, docker-container, docker-image, node-js, tutorial
- Language: Dockerfile
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Minimal Docker-containerized Web-app
This is a minimal Node.js/Express web-application prepared for building
a Docker container.
## Instructions
[Install Docker](https://docs.docker.com/engine/install/). Clone this
repository:
git clone https://github.com/yds12/minimal-containerized-webapp.git
Go to the cloned repository directory (`cd minimal-containerized-webapp`),
and build the docker image of the app:
docker build -t minwebapp .
Check that the image is listed by Docker:
docker images
Run the image, specifying the environment variable PORT and mapping the
container port in the variable to port 3000 on the host machine:
docker run -e PORT=8080 -p 3000:8080 -d minwebapp
The option `-d` is for running the process in the background. Now check that
there is a running container:
docker ps
Take note of the container ID and check the logs of that container:
docker logs
Check that the webserver is responding successfully:
curl -v localhost:3000
Now, kill the process:
docker kill
Check the running containers again to see that it is not running anymore
(`docker ps`). And remove the container:
docker image rm -f minwebapp
Check again the list of images to see that it is not there anymore
(`docker images`).
A nice tutorial for making a Dockerfile for Node.js can be found
[here](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/).