
Before building a Winston logger image on Docker, you will need to install Docker and install NodeJS, and you will probably want to have built the Sails image.
A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
Create a file named Dockerfile.
touch /usr/local/docker/sails/Dockerfile
Append the following to Dockerfile. This will create an image using the latest version of the Winston logger.
FROM node:lts
RUN npm install winston --global
The docker build command can be used to build the image. In this example, /usr/local/docker/sails is the directory that contains the Dockerfile.
docker build --tag nodejs/winston:latest /usr/local/docker/sails
If the install is successful, something like this should be returned.
Successfully built fb60d5e3e7c8
Successfully tagged winston:latest
And the docker images command should return something like this.
~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nodejs/sails latest fb60d5e3e7c8 2 minutes ago 947MB
nodejs/winston latest 406e27a874e7 About a minute ago 973MB
node lts 7528ad312b56 6 days ago 944MB
Did you find this article helpful?
If so, consider buying me a coffee over at