Reputation: 2852
On Windows 11, with this rather simple docker-compose.yaml
file
version: '3.0'
services:
php-apache-environment:
container_name: php-apache
build: ./php
volumes:
- ./php/src:/var/www/html/
ports:
- 8000:80
db:
image: mysql:5.6.27
restart: always
environment:
MYSQL_ROOT_PASSWORD: PassWord
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: 9yI2G0s-sZf37SS5Ml1Kj
ports:
- "9906:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
environment:
PMA_HOST: db
PMA_PORT: 9906
PMA_USER: test
PMZ_PASSWORD: 9yI2G0s-sZf37SS5Ml1Kj
ports:
- '8080:80'
depends_on:
- db
And the command docker compose up --detach
the images are cloned but I get the following error:
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount1583816350/Dockerfile: no such file or directory
In Docker desktop I see the images but as unused.
I googled this error and came up with this but the line dockerfile: Dockerfile
is rejected with:
services.phpmyadmin Additional property dockerfile is not allowed
Upvotes: 5
Views: 5442
Reputation: 39294
I can definitely reproduce this having a an empty php folder, so missing the Dockerfile, with the following minimal example.
File hierarchy:
.
├── docker-compose.yml
└── php
## ^-- mind this is an empty folder, not a file
And the minimal docker-compose.yml:
version: "3.9"
services:
php-apache-environment:
container_name: php-apache
build: ./php
Running docker compose up
yields the same error as yours:
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2757070869/Dockerfile: no such file or directory
So, if you create a Dockerfile in the php folder, e.g.:
.
├── docker-compose.yml
└── php
└── Dockerfile
With a content like
FROM php:fpm
Then the service starts working:
$ docker compose up
[+] Running 1/0
⠿ Container php-apache Created 0.1s
Attaching to php-apache
php-apache | [14-Apr-2023 08:42:10] NOTICE: fpm is running, pid 1
php-apache | [14-Apr-2023 08:42:10] NOTICE: ready to handle connections
And if your file describing the image inside the folder php has a different name than the standard one, which is Dockerfile, then you have to adapt your docker-compose.yml, using the object form of the build
parameter:
version: "3.9"
services:
php-apache-environment:
container_name: php-apache
build:
context: ./php
dockerfile: Dockefile.dev # for example
Related documentation: https://docs.docker.com/compose/compose-file/build/#build-definition
Upvotes: 2