Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to increase the log size in docker when building a container?

Tags:

docker

In the output when building, I am getting this message:

[output clipped, log limit 1MiB reached]

from the command

docker build --progress plain .

The current workaround I have is to pipe larger sections of the RUN command in the dockerfile to /dev/null i.e.

RUN \
 echo "**** install packages ****" && \
 apt-get update && \
 apt-get install -y libcairo2-dev libjpeg-turbo8-dev libpng-dev libtool-bin libossp-uuid-dev wget maven default-jdk > /dev/null
like image 289
alphabet5 Avatar asked Jan 21 '21 00:01

alphabet5


People also ask

How do I change the log level in a docker container?

You can run the command kubectl exec -it <container_name> bash and use the command line inside the container to change the environment variable . You can do it by running the command export LOG_LEVEL=debug or export LOG_LEVEL=error inside the container.

How do I limit the size of a docker log?

To set log limits for containers on a host --log-opt can be configured with max-size and max-file so that a containers logs are rolled over when they reach a max limit and only a certain number of files are saved before being discarded. Restart docker service for the changes to take effect.


5 Answers

With the key link provided by @Luke Deluccia, this is what worked for me.

docker buildx create --use --name larger_log --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000
docker buildx build --progress plain .

This creates a buildx instance, and sets buildx to use the instance when building. This did not clip the logs during the build process.

like image 108
alphabet5 Avatar answered Oct 25 '22 12:10

alphabet5


The other solution is for docker buildx, but some might want a fix for docker build with DOCKER_BUILDKIT=1. The following works for me on ubuntu18.04 and docker version 5:20.10.3~3-0~ubuntu-bionic.

# cat /etc/systemd/system/docker.service.d/env.conf 
[Service]
Environment="BUILDKIT_STEP_LOG_MAX_SIZE=1073741824" # you might want to tweak this
Environment="BUILDKIT_STEP_LOG_MAX_SPEED=10240000"

Then:

systemctl daemon-reload
systemctl restart docker.service
like image 40
Alexander Sergeyev Avatar answered Oct 25 '22 13:10

Alexander Sergeyev


Was on WSL2 docker. The buildx solution somehow didn't work.

But disabling buildkit and piping the output into a file worked for me

So doing this in a bash shell worked for me:

export DOCKER_BUILDKIT=0
docker build --progress plain ./ > logoutput.txt 
like image 26
PeterT Avatar answered Oct 25 '22 12:10

PeterT


for windows:

in cmd run the command:

set DOCKER_BUILDKIT=0

and restart docker desktop

like image 1
Khaled Ahmed Sobhy Avatar answered Oct 25 '22 12:10

Khaled Ahmed Sobhy


Windows 11, Docker Desktop, Docker version 20.10.17.

To turn off BUILDKIT, in the Docker Desktop settings, under "Docker Engine" on the left side, if there's a json block like:

  "features": {
    "buildkit": true
  }

change it to false. If the features block isn't there, it should be under the root {, add it with "buildkit": false.

like image 1
chad Avatar answered Oct 25 '22 14:10

chad