7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker-compose upでエラー「ERROR: In file './docker-compose.yml', volume must be a mapping, not a string.」が発生する

Last updated at Posted at 2019-06-01

はじめに

docker-compose.ymlを作成して、「docker-compose up -d」を実行したところ、以下のようなエラーメッセージが表示されました

ERROR: In file './docker-compose.yml', volume must be a mapping, not a string.

対処法

volumes:key部分に:(コロン)がなかったため、発生していました

docker-compose.yml

エラー時

docker-compose.yml
version: '3'
services:
  db:
    image: mysql:5.7
    volumes:
      - db-volume:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
volumes:
  db-volume

修正後

最後の行に:(コロン)を追加する

docker-compose.yml
version: '3'
services:
  db:
    image: mysql:5.7
    volumes:
      - db-volume:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
volumes:
  db-volume:
7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?