-
Create a folder "docker-node"
-
Change directory
cd docker-node
-
Open VS code here:
code .
-
Inside VS code:
- Open terminal
npm init
creates package.jsonnpm i express
install express and node module gets created.- create "main.js" and write the required code.
-
Create a configuration file for image called
Dockerfile
and write required code -
convert into image:
- syntax : docker build -t(tag) imageKaNaam Dockerfile_ka_path
docker build -t mera-nodejs-image .
-
Run Image inside container
docker run -it imageName
- it will create the container but data will not be visible through browser
- now you need to map the container port to local machine port, so that it can be accessible through the browser
docker run -it -p 8000:8000 imageName
-
docker exec -it containerId bash
- opens a new bash terminal inside the container whose id is specified in the command.
-
ls
- list all available files in the container.
-
cat main.js
- cat show the content of main.js in the command line.
rajmonu/docker
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Docker syllabus practical
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published