Indentation is critical in docker-compose.yml. The way you have it set up, “deploy” is a service, which is not intended. The deploy section is intended to specify information about how the “web” service should be deployed. The following allows docker-compose up and docker stack deploy web --compose-file docker-compose.yml to run successfully for me:
version: "3"
services:
web:
image: tuhina/friendlyhello:2.0
deploy:
replicas: 5
resources:
limits:
cpus: "0.1"
memory: '50M'
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
networks:
webnet: