mirror of https://github.com/docker/compose.git
use platform defined by DOCKER_DEFAULT_PLATFORM when pulling and no service platform defined
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
ea32fc99e1
commit
7c5675c306
|
@ -110,7 +110,7 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
||||||
imagesBeingPulled[service.Image] = service.Name
|
imagesBeingPulled[service.Image] = service.Name
|
||||||
|
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false)
|
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !opts.IgnoreFailures {
|
if !opts.IgnoreFailures {
|
||||||
if service.Build != nil {
|
if service.Build != nil {
|
||||||
|
@ -146,7 +146,8 @@ func imageAlreadyPresent(serviceImage string, localImages map[string]string) boo
|
||||||
return ok && tagged.Tag() != "latest"
|
return ok && tagged.Tag() != "latest"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info, configFile driver.Auth, w progress.Writer, quietPull bool) (string, error) {
|
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info,
|
||||||
|
configFile driver.Auth, w progress.Writer, quietPull bool, defaultPlatform string) (string, error) {
|
||||||
w.Event(progress.Event{
|
w.Event(progress.Event{
|
||||||
ID: service.Name,
|
ID: service.Name,
|
||||||
Status: progress.Working,
|
Status: progress.Working,
|
||||||
|
@ -176,10 +177,14 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
platform := service.Platform
|
||||||
|
if platform == "" {
|
||||||
|
platform = defaultPlatform
|
||||||
|
}
|
||||||
|
|
||||||
stream, err := s.apiClient().ImagePull(ctx, service.Image, moby.ImagePullOptions{
|
stream, err := s.apiClient().ImagePull(ctx, service.Image, moby.ImagePullOptions{
|
||||||
RegistryAuth: base64.URLEncoding.EncodeToString(buf),
|
RegistryAuth: base64.URLEncoding.EncodeToString(buf),
|
||||||
Platform: service.Platform,
|
Platform: platform,
|
||||||
})
|
})
|
||||||
|
|
||||||
// check if has error and the service has a build section
|
// check if has error and the service has a build section
|
||||||
|
@ -269,7 +274,7 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
|
||||||
for i, service := range needPull {
|
for i, service := range needPull {
|
||||||
i, service := i, service
|
i, service := i, service
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
id, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, quietPull)
|
id, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||||
pulledImages[i] = id
|
pulledImages[i] = id
|
||||||
if err != nil && isServiceImageToBuild(service, project.Services) {
|
if err != nil && isServiceImageToBuild(service, project.Services) {
|
||||||
// image can be built, so we can ignore pull failure
|
// image can be built, so we can ignore pull failure
|
||||||
|
|
Loading…
Reference in New Issue