I don’t know that book but the example was probably not meant to be used on Mac. You can use the syslog driver if you have a remote Syslog server but the virtual machine on Mac does not include syslog. See the documentation: Syslog logging driver | Docker Documentation
I quote the example:
docker run \
--log-driver syslog --log-opt syslog-address=udp://1.2.3.4:1111 \
alpine echo hello world
If you don’t have a remote syslog and you still want to test it on Mac, you can try to install a Syslog server in a Docker container: