Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - Watch logs in real time while building image

Tags:

npm

docker

I'm building a Docker image from a Dockerfile, but I dont know if when I execute the npm install command, the server is installing the dependencies from packege.json. I want to check in real time the progress of the dependencies installation, is it possible?

CMD:
docker build -t angular-frontend:prod .

OUTPUT:

Sending build context to Docker daemon 1.264 MB
Step 1 : FROM node:carbon
---> 99bbd77c18fe
Step 2 : WORKDIR /app
---> Running in 1d914a408725
---> fca47246ff16
Removing intermediate container 1d914a408725
Step 3 : COPY package.json /app/
---> 793227e711d4
Removing intermediate container 1f9c5341747e
Step 4 : RUN npm install
---> Running in ddee013be29c

What do I want: See whats happening inside the container. Any hints?

like image 935
dpolicastro Avatar asked Mar 05 '18 17:03

dpolicastro


People also ask

How do you access container logs in container runtime?

First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.


1 Answers

This is not a Docker problem. Docker outputs the logs during build. For instance, if you do RUN composer update in your Dockerfile, then you get the output. For example, here's our RUN composer update output during Dockerfile build on codeship:

our RUN composer update

See? The output is right there! So, what you need is to tell your npm to log verbosely:

RUN npm install --loglevel verbose

This should output the logs in real time and also save your log into npm-debug.log file.

like image 197
Alex Karshin Avatar answered Sep 30 '22 18:09

Alex Karshin