A Simple nodejs app using docker
- Building your image
Go to the directory that has your Dockerfile and run the following command to build the Docker image. The -t flag lets you tag your image so it's easier to find later using the docker images command:
docker build . -t node-web-app
- Your image will now be listed by Docker:
docker images
- Run the image Running your image with -d runs the container in detached mode, leaving the container running in the background. The -p flag redirects a public port to a private port inside the container. Run the image you previously built:
docker run -p 3000:3000 -d node-web-app
- Get container ID
docker ps
- Print app output
docker logs <container id>
Server: Node, Express, Docker
Hit api "http://localhost:3000