I would like build custom Dockerfile, but i've this message :
--> Starting build app
ERROR: The Compose file is invalid because:
Service app has neither an image nor a build context specified. At least one must be provided.
I don't understand why the name is app
. You can see my docker-compose.yml file :
version: "3"
services:
webapp-react:
build:
context: ./docker/nodejs
dockerfile: Dockerfile
image: webapp/react
container_name: webapp_react
user: ${UID}:${GID}
environment:
- NODE_ENV=build
webapp-nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
image: webapp/nginx
container_name: webapp_nginx
environment:
- VIRTUAL_HOST=${SITE_URL}
- VIRTUAL_PORT=8080
- VIRTUAL_NETWORK=nginx-proxy
- LETSENCRYPT_HOST=${SITE_URL}
- LETSENCRYPT_EMAIL=${MAILER_DEFAUT_SENDER_ADDRESS}
ports:
- "8181:80"
volumes:
- ./app/build:/www-data/
networks:
default:
external:
name: nginx-proxy
Anyone know where did I make an error ?
Thank you !
In my case, I had renamed the services in the docker-compose.yml
file, but forgot to do the same in docker-compose.override.yml
and docker-compose.vs.release.yml
.
The below applies everywhere that docker-compose is used. I use visual studio docker tools as reference
Quick answer:
I would thoroughly look at my
docker-compose.override.yml
files for references of thedefined service
in the error description. Thendelete
it. The error mentions that you have a service that is defined in theoverride file
but not on thebase docker-compose file
.
Reproduce the problem with visual studio.
I came across the same issue with my docker-compose.
Visual studio also populates docker-compose.override.yml
by default. When you append services.
Like @Jorn.Beyers mentioned this can be easily replicated if you are using docker tools for visual studio. Append some services run your docker-compose and afterward start removing services or services from your docker-compose.yml.
The OP's descriptive error will appear.
I am not sure if you clean the solution with visual studio you get rid of this problem. It did not work for me.
What I did and solved the problem?
What I did was I located the place where docker-compose
is. I found that there is a docker-compose.override.yml
. Which still references the service I deleted.
So what I did was locate the service inside my docker-compose.override.yml
. In the below case I still reference sth.blog.api
.
sth.blog.api: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=https://+:443;http://+:80 ports: - "80" - "443" volumes: - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
Looked similar to the above. After I deleted these lines. I restarted docker-compose and everything runs.
Note
Since I use visual studio and its magical auto-gen tools. Which I guess is where this error mostly appears and can be intimidating, since especially for beginners, the error description gives you the above error and when clicking on the error takes you to a very strange file and not at the source of the problem.
More info about container tool inside visual studio: https://docs.microsoft.com/en-us/visualstudio/containers/?view=vs-2019
I got the same issue when I was removing some applications from the docker-compose and docker-compose-override file in Visual Studio 2019. Cleaning the solution before running docker-compose again did work for me.
In my case, i added service in docker-compose.override.yml
file, but forgot to add it into docker-compose.yml file
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With