Here is my docker-compose.yml:
version: '2'
services:
web:
  build: .
  context: ./
  dockerfile: Dockerfile
  ports:
    - "8080:8080"
  container_name: demo
  volumes:
    - .:/images
I got an error:
ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services.web: 'dockerfile'
So I would like to build the container and also run. I will have a few more containers to build and run. Is it possible by docker-compose?
If I'm not mistaken the issue is after build you have a dot, the dockerfile and context are not correct idented. And I think the bar in the context should not be there.
version: "3.7"
services:
  api:
    image: image-name
    build:
      context: .
      dockerfile: path/to/Dockerfile
    container_name: container-name
I think this resolves the issue you have, but couldn't test it.
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