Mac M1 上的 Docker - 卷无法解析相对路径

时间:2021-01-09 00:28:08

标签: docker docker-compose docker-volume

我的目录结构是 ~/db/migrations/ 我有一个 docker compose 文件。在运行 docker-compose up 时,它会抛出错误为 error: open /db/migrations: no such file or directory 。我怀疑它是 M1 docker 中的一个错误。有没有其他人遇到过类似的问题?

    version: '3.7'
services:
  database:
    image: postgres
    networks:
      db_network:
        aliases:
          - database_network
    env_file:
      - database.env
    volumes:
      - database-data:/var/lib/postgresql/data/
    ports:
      - "5432:5432"
  migrate:
    image: migrate/migrate
    networks:
      - db_network
    volumes:
      - .:/db/migrations
    command: ["-path", "/db/migrations/", "-database",  "postgres://memories_user:memories_password@database:5432/memories_dev?sslmode=disable", "up", "3"]
    links:                                                                                                                                                                   
      - database                                                                                                                                                             
networks:                                                                                                                                                                    
  db_network:                                                                                                                                                                
volumes:                                                                                                                                                                     
  database-data: ~                                                                                                                                                           

1 个答案:

答案 0 :(得分:0)

对卷进行小幅调整解决了这个问题。

volumes:
  - ./db/migrations:/migrations
command: ["-path", "/migrations", "-database",  "postgres://memories_user:memories_password@database:5432/memories_dev?sslmode=disable", "up", "3"]