https://github.com/stuartdaniells/basic_server_docker_container
Docker container to create a simple/dummy express server listening on port 3000
https://github.com/stuartdaniells/basic_server_docker_container
docker dockerfile dockerimage expresss nodejs
Last synced: 2 months ago
JSON representation
Docker container to create a simple/dummy express server listening on port 3000
- Host: GitHub
- URL: https://github.com/stuartdaniells/basic_server_docker_container
- Owner: StuartDaniells
- Created: 2022-12-26T22:56:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T23:12:39.000Z (over 2 years ago)
- Last Synced: 2023-12-01T05:27:14.963Z (over 1 year ago)
- Topics: docker, dockerfile, dockerimage, expresss, nodejs
- Language: Dockerfile
- Homepage:
- Size: 630 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
## 1. To create an image of the curr. dir.
`docker build .`---
## 2. Docker image id:
`cafc1e2ef3e59dc1169b917dbae80453fa5000bd3222f504aefea593a62c28b7`---
## 3. To create a container based on this image, run: (read next point)
`docker run cafc1e2ef3e59dc1169b917dbae80453fa5000bd3222f504aefea593a62c28b7`---
## 4. However since we want to expose/publish a port, to connect to on this container we are running, we instead run:
`docker run -p 3000:3000 cafc1e2ef3e59dc1169b917dbae80453fa5000bd3222f504aefea593a62c28b7`**The above cmd exposes port 3000 on the current localhost machines port 3000**
Since there is no connection between the container and local OS, we do the below, to send http requests & responses to the app in this container
+ *-p 3000: publishes/listen in containers port 3000 only*
+ *-p 3000:3000 opens up the containers port 3000 to the local machines port 3000*---
## 5. To list all running container:
`docker ps`---
## 6. To stop a running container:
`docker stop 'NAME'`---
> Note:
> 1) .cjs - uses Nodejs old default module system - CommonJs - require
> 2) .mjs - uses Nodejs native module system - ECMAScript - import & export