ERROR: In file '.\docker-compose.yml', vol

2019-08-13 14:03发布

I have a developed site in Wordpress with a custom template. So i got only the wp-content folder since it contains all the template related files and plugins. With the Database dump. Finally defined the correct Wordpress image, MySQL versions in a "docker-compose.yml" like this.

version: '3.3'

services:
  db:
  image: mysql:5.6
  volumes:
    - db/user_portaldb.mysql.sql:/var/lib/mysql
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress:4.9.7
    ports:
      - "8000:80"
    restart: always
    volumes:
      - user_portal/wp-content:/var/www/html/wp-content
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
volumes:
  user_portal/wp-content
db:
  db/user_portaldb.mysql.sql

Once i executed this docker command,

docker-compose up -d

I'm getting this error:

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

I have installed Docker in my Windows environment.

1条回答
虎瘦雄心在
2楼-- · 2019-08-13 14:32

You can use:

- ./userportal/wp-content:/var/www/html/wp-content

for your volume. docker-compose and docker stack deploy understand relative paths for volume names with that syntax. Without the leading ./ it will interpret the string as a named volume. See the short syntax for volumes for more details: https://docs.docker.com/compose/compose-file/#short-syntax-3

查看更多
登录 后发表回答