We have seen that the logging driver can be set globally in the Docker daemon configuration file. But we can also define the logging driver on a container by container basis. In the following example, we are running a busybox container and use the --log-driver parameter to configure the none logging driver:
$ docker container run --name test -it \
--log-driver none \
busybox sh -c 'for N in 1 2 3; do echo "Hello $N"; done'
We should see the following:
Hello 1 Hello 2
Hello 3
Now, let's try to get the logs of the preceding container:
$ docker container logs test
The output is as follows:
Error response from daemon: configured logging driver does not support reading
This is to be expected, since the none driver does not produce any logging output. Let's clean up and remove the test container:
$ docker container rm test