Docker-Compose 无法在 Docker Apple Silicon Tech Preview 中运行? (苹果硅m1)

时间:2021-04-15 09:53:37

标签: docker docker-compose apple-m1

我在下面有简单的 docker-compose.yml,它适用于我的 MacBook Pro 15"(普通英特尔处理器)

version: "3.0"
services:
  elasticsearch:
    container_name: es-container
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
    environment:
      - xpack.security.enabled=false
      - "discovery.type=single-node"
    networks:
      - es-net
    ports:
      - 9200:9200
  kibana:
    container_name: kb-container
    image: docker.elastic.co/kibana/kibana:7.11.0
    environment:
      - ELASTICSEARCH_HOSTS=http://es-container:9200
    networks:
      - es-net
    depends_on:
      - elasticsearch
    ports:
      - 5601:5601
networks:
  es-net:
    driver: bridge

使用 docker-compose up -d 运行它可以正常工作。

当我转向 M1 MacBook Pro 时,我需要从 https://docs.docker.com/docker-for-mac/apple-m1/

下载 Docker

当我尝试使用 docker-compose -up -d 在 M1 MacBookPro 中运行时,它出错

Traceback (most recent call last):
  File "docker/api/client.py", line 268, in _raise_for_status
  File "requests/models.py", line 941, in raise_for_status
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/version

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 214, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/api/client.py", line 274, in _result
  File "docker/api/client.py", line 270, in _raise_for_status
  File "docker/errors.py", line 31, in create_api_error_from_http_exception
docker.errors.APIError: 500 Server Error for http+docker://localhost/version: Internal Server Error ("b'dial unix docker.raw.sock: connect: connection refused'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 198, in perform_command
  File "compose/cli/command.py", line 60, in project_from_options
  File "compose/cli/command.py", line 152, in get_project
  File "compose/cli/docker_client.py", line 41, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 197, in __init__
  File "docker/api/client.py", line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: 500 Server Error for http+docker://localhost/version: Internal Server Error ("b'dial unix docker.raw.sock: connect: connection refused'")
[14529] Failed to execute script docker-compose

这似乎类似于此问题 https://github.com/docker/for-win/issues/9561,但这是针对 Apple M1 MacBook。这是 Docker 中的错误,还是我自己的问题?

1 个答案:

答案 0 :(得分:0)

与您的 docker-compose 相关的东西。 我可以在 M1 MacBook 上使用最新的 Docker for Apple Silicon 运行您的撰写文件。 https://www.docker.com/products/docker-desktop(最近 docker 为 Apple Silicon 发布了稳定版)

尝试列出 docker-compose 可执行文件的路径

➜ which docker-compose
/usr/local/bin/docker-compose

我的 docker-compose 版本:

➜ docker-compose -v
docker-compose version 1.29.0, build 07737305

这是在我的机器上运行的 docker-compose 配置的日志(MacBook Pro 13 M1):

➜ docker-compose up
Docker Compose is now in the Docker CLI, try `docker compose up`

Creating network "test-dk_es-net" with driver "bridge"
Pulling elasticsearch (docker.elastic.co/elasticsearch/elasticsearch:7.11.0)...
7.11.0: Pulling from elasticsearch/elasticsearch
0122c235edee: Pull complete
9bc50b2741f6: Pull complete
4697480b6de2: Pull complete
addd2fd0c5df: Pull complete
36f20916e73d: Pull complete
2fd6f9204a99: Pull complete
cb1cc36d3a3f: Pull complete
Digest: sha256:c16cb4fcb0b430d1f30bbde6b1e0226b944520df7a6085a39441d14abbac2f6d
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.11.0
Pulling kibana (docker.elastic.co/kibana/kibana:7.11.0)...
7.11.0: Pulling from kibana/kibana
ddf49b9115d7: Pull complete
d4944b1aa16c: Pull complete
00406464e965: Pull complete
3666deb86000: Pull complete
fad0f7771f2d: Pull complete
9daae5ea93be: Pull complete
e4a69158d06c: Pull complete
e81f4cc9df48: Pull complete
f2fbcfd511fc: Pull complete
128d517a074d: Pull complete
84806a584b82: Pull complete
d89280647d9a: Pull complete
c8ab7b259186: Pull complete
Digest: sha256:a5d3bfd888ca04da641a5839310498938cc000037ff7d54ba3050f5d6d470c4d
Status: Downloaded newer image for docker.elastic.co/kibana/kibana:7.11.0
Creating es-container ... done
Creating kb-container ... done
Attaching to es-container, kb-container
es-container     | {"type": "server", "timestamp": "2021-04-18T18:35:38,290Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "9aa0bb307dfb", "message": "version[7.11.0], pid[9], build[default/docker/8ced7813d6f16d2ef30792e2fcde3e755795ee04/2021-02-08T22:44:01.320463Z], OS[Linux/5.10.25-linuxkit/aarch64], JVM[AdoptOpenJDK/OpenJDK 64-Bit Server VM/15.0.1/15.0.1+9]" }
es-container     | {"type": "server", "timestamp": "2021-04-18T18:35:38,292Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "9aa0bb307dfb", "message": "JVM home [/usr/share/elasticsearch/jdk], using bundled JDK [true]" }
es-container     | {"type": "server", "timestamp