To use docker command you must change docker.sock permissions on the docker service where jenkins is running.
To automate the docker.sock permissions follow these steps:
wget https://github.com/aramirol/custom-resources/blob/main/kubernetes/docker.sock/docker_sock_acl.sh
wget https://github.com/aramirol/custom-resources/blob/main/kubernetes/docker.sock/docker_sock.service
cp docker_sock_acl.sh <path_you_want>
chmod 744 <path_you_want>/docker_sock_acl.sh
cp docker_sock.service /etc/systemd/system/docker_sock.service
sysmtectl daemon-reload
systemctl enable docker_sock.service
systemctl start docker_sock.service
After that, you can restart your server and check that the permissions have changed automatically.