Reputation: 60081
I have simple docker-compose.yml below, that works in my MacBook Pro 15" (normal Intel Processor)
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
Running it using docker-compose up -d
works fine.
As I move over to M1 MacBook Pro, I need to download Docker from https://docs.docker.com/docker-for-mac/apple-m1/
When I try to run in M1 MacBookPro using docker-compose -up -d
, it errors out
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
This seems similar to this issue https://github.com/docker/for-win/issues/9561, but this is for Apple M1 MacBook. Is this a bug in Docker, or my own issue?
Upvotes: 4
Views: 22553
Reputation: 532
you need to add the line platform: linux/amd64
in the service section. And with that your container gona run like a linux environment. Ill show you an example:
version: "3.0"
services:
elasticsearch:
platform: linux/amd64 # mac environment line only
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
Then with that line added, execute docker compose up -d
or docker-compose up -d
, depends of the version of your docker compose (newers versions are with out -)
Upvotes: 0
Reputation: 1033
You need to set the following environment variables which informs docker to not to use buildkit and use arm64 as the default platform
export DOCKER_DEFAULT_PLATFORM=linux/arm64
export DOCKER_BUILDKIT=0
Upvotes: 1
Reputation: 4058
Changing single quotes version: '2.2' to double quotes like "2.2" in the docker-compose did the trick. Add double quotes to the version.
Upvotes: 0
Reputation: 21
I get a similar error only when Docker Desktop is not running. I suggest you try with a running Docker Desktop in the background.
My docker-compose version:
% docker-compose -v
docker-compose version 1.29.2, build 5becea4c
I'm running it on macOS Monterey version 12.0.1 on an M1 Max.
Upvotes: 2
Reputation: 499
Something with your docker-compose. I can run your compose file using the latest Docker for Apple Silicon on my M1 MacBook. https://www.docker.com/products/docker-desktop (recently docker released stable version for Apple Silicon)
Try to list the path to the docker-compose
executable
➜ which docker-compose
/usr/local/bin/docker-compose
My docker-compose version:
➜ docker-compose -v
docker-compose version 1.29.0, build 07737305
Here the log from your docker-compose config running on my machine (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
Upvotes: 2