Building Your Image
After creating a Dockerfile build an image using the help Dockerfile by using the following command.
docker build -t docker-container-nodejs .
The command uses the flag -t to specify the name of the image, and then we have to give the address where. Then, our Dockerfile is situated; since we are in the directory while running the commands, we can use the period, which stands for the current directory.
- Confirm that the image has been created.
docker images
The output will be a list of images in your system. It should contain our recently created image with the name we provided with the -t flag.
- To run the docker container with this image, use the following command.
Docker – Docker Container for Node.js
Node.js is an open-source, asynchronous event-driven javascript runtime that is used to run javascript applications. It is widely used for traditional websites and as API servers. At the same time, a docker container is an isolated, deployable unit that packages an application along with its dependencies, making it highly scalable and maintainable. In this article, we will create a docker container for node.js and run a simple express.js application on the container.