extra host for build does not work
<!--
Welcome to the docker-compose issue tracker! Before creating an issue, please heed the following:

1. This tracker should only be used to report bugs and request features / enhancements to docker-compose
    - For questions and general support, use https://forums.docker.com
    - For documentation issues, use https://github.com/docker/docker.github.io
    - For issues with the `docker stack` commands and the version 3 of the Compose file, use
      https://github.com/docker/cli
2. Use the search function before creating a new issue. Duplicates will be closed and directed to
   the original discussion.
3. When making a bug report, make sure you provide all required information. The easier it is for
   maintainers to reproduce, the faster it'll be fixed.
-->

## Description of the issue
On windows, with docker 20.10.5.
Since the update, it is impossible to add hosts to the /etc/hosts (read-only). As it is needed to add some hosts for the build, I'd like to add hosts using the extra-hosts:
```
  svc1:
    build:
      context: build/svc1
      extra_hosts:
      - "test.be:127.0.0.1"
    hostname: svc1
```
The output of docker-compose build svc1 is

```
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\\cli\\main.py", line 80, in main
  File "compose\\cli\\main.py", line 192, in perform_command
  File "compose\\metrics\\decorator.py", line 18, in wrapper
  File "compose\\cli\\main.py", line 357, in build
  File "compose\\project.py", line 519, in build
  File "compose\\project.py", line 501, in build_service
  File "compose\\service.py", line 1131, in build
  File "compose\\progress_stream.py", line 22, in stream_output
  File "compose\\utils.py", line 50, in split_buffer
  File "compose\\utils.py", line 26, in stream_as_text
  File "compose\\service.py", line 1880, in build
AttributeError: 'list' object has no attribute 'items'
[3144] Failed to execute script docker-compose
```

It seems to accept it for
```
  svc1:
    build:
      context: build/svc1
      extra_hosts: {"test.be:127.0.0.1"}
    hostname: svc1
```
but then the output is:
```
invalid argument "test.be:127.0.0.1:None" for "--add-host" flag: invalid IP address in add-host: "127.0.0.1:None"
```

## Context information (for bug reports)

**Output of `docker-compose version`**
```
docker-compose version 1.28.5, build c4eb3a1f
docker-py version: 4.4.4
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
```

**Output of `docker version`**
```
Client: Docker Engine - Community
 Cloud integration: 1.0.9
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:14:53 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
```


diff --git a/compose/service.py b/compose/service.py
index 3829e826..53cf42ae 100644
--- a/compose/service.py
+++ b/compose/service.py
@@ -1877,8 +1877,10 @@ class _CLIBuilder:
         command_builder.add_arg("--isolation", isolation)
 
         if extra_hosts:
-            for host, ip in extra_hosts.items():
-                command_builder.add_arg("--add-host", "{}:{}".format(host, ip))
+            if isinstance(extra_hosts, dict):
+                extra_hosts = ["{}:{}".format(host, ip) for host, ip in extra_hosts.items()]
+            for host in extra_hosts:
+                command_builder.add_arg("--add-host", "{}".format(host))
 
         args = command_builder.build([path])
 
['compose/service.py']