Fix createService not passing registry auth#116
Merged
Conversation
Dockerode's createService single-arg codepath does NOT extract
authconfig from the options object (unlike createImage and
service.update which do). Passing {…serviceSpec, authconfig}
resulted in the entire service spec being serialized as the
X-Registry-Auth header, which the registry cannot parse.
Use the two-argument form createService(auth, opts) so the auth
config is correctly sent as the X-Registry-Auth header.
Docker Swarm's task agent doesn't understand the raw base64 auth field from docker config. It needs explicit username and password fields in the X-Registry-Auth header. Also fix createService to pass auth as a separate first argument, since dockerode's single-arg codepath for createService doesn't extract authconfig from the options (unlike service.update). Tested locally: docker service create with the decoded auth successfully pulls from registry.cego.dk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
authfield from~/.docker/config.json— it needs explicitusername/passwordfields in theX-Registry-Authheaderauthfield (base64-encodedusername:password) into separateusernameandpasswordfields before sendingcreateServiceto pass auth as a separate first argument, since dockerode's single-arg codepath forcreateServicedoesn't extractauthconfigfrom the options (unlikeservice.update)Test plan
docker service create --with-registry-auth(Docker CLI) also fails with same error — confirming the raw auth field format is the issueusername/passwordauth via Docker API succeedsregistry.cego.dksuccessfully