Skip to content

Docker container to create a simple/dummy express server listening on port 3000

Notifications You must be signed in to change notification settings

StuartDaniells/basic_server_docker_container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Docker container to create a simple/dummy express server listening on port 3000

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages