Docker Community Forums

Share and learn in the Docker community.

Docker compose command failed and build failed returns non-zero: 2

For a schoolproject I need to load a localhost/db(mssql) container with connection in docker. On my windows machine it works perfectly but when I follow the same procedures on my Mac I get the errors shown below.

I got the error when I reopened a git cloned files (with docker-compose.yml and dockerfile) in a container (via vs code) but when I do, I get an error that the service ‘’ failed to build and returned a non-zero code of 2. after that I get a fail on docker-compose see linked below the full message

ERROR: Service 'webserver' failed to build : The command '/bin/sh -c /root/provision.sh' returned a non-zero code: 2
[13240 ms] Command failed: docker-compose --project-name webtech-is-env -f /Users/martijn/Documents/Development/webtech-is-env/docker-compose.yml up -d --build

Mac Specs:
2020 M1 chip,
Big Sur
Docker m1 preview version

docker specs:
CPU available 2GB,
Memory available 4GB,
Swap available 1GB,
Disk space available 200GB

Docker is running locally on my machine.

Docker-compose.yml:

version: “3.7”
services:
webserver:
build: .
command: |-
php -S 0.0.0.0:80 -t /srv/webserver/applicatie/public/
working_dir: “/srv/webserver/applicatie”
# TODO: check how to restrict to localhost
ports:
- target: “80”
published: “8000”
protocol: tcp
mode: bridge
healthcheck:
test: [“CMD”, “curl”, “-f”, “http://127.0.0.1”]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
- ./:/srv/webserver/:cached

Docker file:

FROM php:7.4.6-cli-alpine3.11
VOLUME /srv/webserver
COPY ./provision.sh /root/provision.sh
RUN /root/provision.sh
WORKDIR /srv/webserver/

devcontainer.json file:

{
“name”: “PHP”,
“dockerComposeFile”: [“docker-compose.yml”],
“service”: “webserver”,
“workspaceFolder”: “/srv/webserver”,
“shutdownAction”: “none”,
“extensions”: [
“sleistner.vscode-fileutils”,
“timonwong.shellcheck”,
]
}