8

I sometimes get warnings or non fatal errors when building an image. For instance, if I compile some program inside a Docker image, but some optional library is missing, a warning is printed.

But if the image keeps building, the message is difficult to retrieve, because the terminal keeps scrolling down and at some point, it is too high up to be readable.

Is it possible to pause a Docker image or to retrieve these error messages some other way than outputting to a file (which might loose the coloring the terminal has) ?

conradkleinespel
  • 6,560
  • 10
  • 51
  • 87

2 Answers2

7

Is it possible to pause a Docker image

no, you cannot pause the docker build command.


You could give a try to the Scroll Lock key, but depending on your terminal that might fail.


You could pipe the result of the docker build command to less -R:

docker build -t test . | less -R

Once built, you can then use the arrow keys to go up and down, use / to search for test, etc.

-R is to keep colors

-r  -R  ....  --raw-control-chars  --RAW-CONTROL-
                Output "raw" control characters.

Also you can record the output to a file (I know you explicitly said you don't want this solution, but it can suit others):

docker build -t test . | tee build.log
Thomasleveil
  • 95,867
  • 15
  • 119
  • 113
0

While i understand you would rather not prefer the exit code being transported to the file, i can assure you the coloring will not be lost.

A simple code that i use to relay errors, such as info's and fatals,

docker build $(pwd) 2>> error

will transmit any errors that prevented it from building the image into an error file.

Upon cat of the file, the color code of the errors remain. Typically my aim for this is to use these errors in order to build a docker image that can build itself from these errors.

I understand that if you wanted to pause a docker build, you could for say cancel it using ^c (control c) which will terminate the active process in a window. Of course you wouldn't be able to unpause it.

I get these solutions were not what you are looking for, but its the only way i am currently aware of in order to do what you want.

Community
  • 1
  • 1
Jouster500
  • 762
  • 12
  • 25