We will create a simple Node JS application and dockerize it. We will use the official Node JS image(alpine) from Docker Hub.You can find the official Node JS image here.
- Docker installed on your machine. You can download Docker from here.
- Create docker image for Node JS application with the following command:
docker build -t nodejs-app .
After running the above command, it will create a docker image with the name nodejs-app
. we can view the list of docker images with the following command:
docker images
- Run the docker container with the following command:
docker run -d -p 3000:3000 nodejs-app
It will run the docker container in detached mode and expose the port 3000. We can view the list of running docker containers with the following command:
docker container ps