skip to Main Content

I have a docker compose file that looks like this:

version: '3.8'
services:
  db:
    image: mysql
    ports:
      - 3306:3306
 environment:
      MYSQL_DATABASE: db
      MYSQL_ALLOW_EMPTY_PASSWORD: true

however, I am getting this error when I run docker-compose up:

The Compose file ‘.docker-compose.yml’ is invalid because:
services.db.environment.MYSQL_ALLOW_EMPTY_PASSWORD contains true, which is an invalid type, it should be a string, number, or a null

I don’t really understand why I’m getting this error because I’ve seen other examples of docker compose files with the value set to true. Any advice on what I’m doing wrong here?

2

Answers


  1. Chosen as BEST ANSWER

    Just figured it out. Looks like I needed to change "true" to 1. Here's my final file which works now:

    version: '3.8'
    services:
      db:
        image: mysql
        ports:
          - 3306:3306
     environment:
          MYSQL_DATABASE: db
          MYSQL_ALLOW_EMPTY_PASSWORD: 1
    

  2. You cannot pass a boolean value, that’s why you are getting this error. "true" (without the quotes) gets converted to True, which is a boolean value.

    Looking at the docker hub page it says it only has to be a non-empty value.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search