Can I pause a Docker build?

I sometimes get warnings or non-fatal errors while creating the image. For example, if I compile some program inside a Docker image, but some additional library is missing, a warning is displayed.

But if the image continues to build, the message is difficult to retrieve because the terminal keeps scrolling down and at some point it is too high to read.

Is it possible to pause the Docker image, or get these error messages in a different way than outputting to a file (which can lose terminal coloration)?

+3


source to share


2 answers


Is it possible to pause the Docker image

no, you cannot pause the command docker build

.


You can try the key Scroll Lock, but depending on your terminal that might fail.


You can pipe the result of the command docker build

to less -R

:

docker build -t test . | less -R

      



Once created, you can use the up and down arrow keys, use /

to search for a test, etc. ...

-R

- keep colors

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

      


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

docker build -t test . | tee build.log

      

+3


source


While I understand that you would prefer that the exit code not be carried over to the file, I can assure that the coloring will not be lost.

Simple code that I use to relay errors like info and facts,

docker build $(pwd) 2>> error

      

will pass any errors that prevented it from creating an image in the error file.



The cat

error color code is saved in the file. Usually my goal is to use these errors to create a docker image that can build itself out of these errors.

I understand that if you want to pause a docker build you can cancel it using ^c

(control c) which will terminate the active process in the window. Of course, you cannot unlock it.

I get that these solutions were not what you are looking for, but this is the only way I currently know to do what you want.

0


source







All Articles