We have a process that fetches a file from one repo then push to different repository.
We have discovered that the docker.withRegistry create a new `DOCKER_CONFIG` for each docker.withRegistry and traced it to `org.jenkinsci.plugins.docker.commons.impl.RegistryKeyMaterialFactory`.
Per each materialize() there is unconditional call to `createSecretsDirectory()` which loses loses the credentials in previous block.
In this implementation only a single docker registry may be authenticated, while docker supports many.
- Do not create new secrets directory if already exist, it can be checked via the `DOCKER_CONFIG` variable. Maybe force first time creation within the entire instance to isolate jenkins from system.
- Use docker logout instead of removing `DOCKER_CONFIG` to clean up the credentials.
If this is acceptable I may be able to provide a patch.