Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported config option for services.web: 'dockerfile'

I am setting up a new environment with php and mysql in docker. i am using docker-compose file. while installing i realize that i need few more PHP extentensions. I have gone through suggestion online where it is suggested to write a docker file and call it in docker-compose.yml. it is alwasy showing below error Unsupported config option for services.web: 'dockerfile'

please find docker-compose.yml and Dockerfile below

docker-compose.yml

version: '3'
services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: asdf
      # MYSQL_DATABASE: test_db
      # MYSQL_USER: root
      # MYSQL_PASSWORD: asdf
    volumes:
      - /var/mysql/:/var/lib/mysql
    ports:
      - "3306:3306"
  web:
    # image: alankar1985/php7.2:apache2
    container_name: php_web
    dockerfile: Dockerfile
    # command: apt-get install -y php-gd
    depends_on:
      - db
    volumes:
      - /var/www/html/:/var/www/html/
    ports:
      - "80:80"
    stdin_open: true
    tty: true

Dockerfile

FROM alankar1985/php7.2:apache2

RUN apt install php-gd


Unsupported config option for services.web: 'dockerfile'

like image 659
Alankar Avatar asked Aug 19 '19 15:08

Alankar


People also ask

Why is docker-compose-yml file invalid?

#docker-compose up ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services.show: 'dockerfile' services.show.build contains an invalid type, it should be a string, or an object services.movies.build contains unsupported option: 'networks'

What is the latest version of Docker-Compose support for version 2 format?

Support for the version 2 compose file format was introduced in docker-compose version 1.6, released around February of this year. You're using 1.3.3, from July 2015. You need to upgrade to a more recent version to use the version 2 format configuration files.

Is docker-compose compatible with GPU?

See also, Compose command compatibility with docker-compose. Docker Compose v1.27.0+ switched to using the Compose Specification schema which is a combination of all properties from 2.x and 3.x versions. This re-enabled the use of service properties as runtime to provide GPU access to service containers.


1 Answers

The best way to troubleshoot these type of issues is checking the docker-compose reference for the specific version - https://docs.docker.com/compose/compose-file/.

Without testing, the issue is because you need to put dockerfile under build.

Old:

web:
  dockerfile: Dockerfile

New:

web:
  build:
    context: .
    dockerfile: Dockerfile

Since you are using the standard Dockerfile filename, you could also use:

build:
  context: .

From reference page:

DOCKERFILE Alternate Dockerfile.

Compose uses an alternate file to build with. A build path must also be specified.

build:
  context: .
  dockerfile: Dockerfile-alternate
like image 74
leeman24 Avatar answered Sep 26 '22 22:09

leeman24