@@ -348,8 +348,8 @@ func WithUIDGID(uid, gid uint32) SpecOpts {
348348
349349// WithUserID sets the correct UID and GID for the container based
350350// on the image's /etc/passwd contents. If /etc/passwd does not exist,
351- // or uid is not found in /etc/passwd, it sets gid to be the same with
352- // uid , and not returns error.
351+ // or uid is not found in /etc/passwd, it sets the requested uid,
352+ // additionally sets the gid to 0 , and does not return an error.
353353func WithUserID (uid uint32 ) SpecOpts {
354354 return func (ctx context.Context , client Client , c * containers.Container , s * specs.Spec ) (err error ) {
355355 setProcess (s )
@@ -362,7 +362,7 @@ func WithUserID(uid uint32) SpecOpts {
362362 })
363363 if err != nil {
364364 if os .IsNotExist (err ) || err == errNoUsersFound {
365- s .Process .User .UID , s .Process .User .GID = uid , uid
365+ s .Process .User .UID , s .Process .User .GID = uid , 0
366366 return nil
367367 }
368368 return err
@@ -388,7 +388,7 @@ func WithUserID(uid uint32) SpecOpts {
388388 })
389389 if err != nil {
390390 if os .IsNotExist (err ) || err == errNoUsersFound {
391- s .Process .User .UID , s .Process .User .GID = uid , uid
391+ s .Process .User .UID , s .Process .User .GID = uid , 0
392392 return nil
393393 }
394394 return err
0 commit comments