错误:在文件'.\docker-compose.yml'中,卷必须是映射,而不是字符串。 -带有Wordpress的Docker [英] ERROR: In file '.\docker-compose.yml', volume must be a mapping, not a string. - Docker with Wordpress

查看:443
本文介绍了错误:在文件'.\docker-compose.yml'中,卷必须是映射,而不是字符串。 -带有Wordpress的Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Wordpress中有一个带有自定义模板的开发站点。所以我只有wp-content文件夹,因为它包含所有与模板相关的文件和插件。随着数据库转储。最后,在这样的 docker-compose.yml中定义了正确的Wordpress图像和MySQL版本。

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

我执行此docker命令后,

Once i executed this docker command,

docker-compose up -d

我收到此错误:

错误:在文件'.\docker-compose.yml'中,volume必须是映射,而不是字符串。

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

我已经在Windows环境中安装了Docker。

I have installed Docker in my Windows environment.

推荐答案

您可以使用:

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

您的音量。 docker-compose docker stack deploy 了解具有该语法的卷名的相对路径。如果没有前导 ./ ,它将把字符串解释为一个命名卷。有关更多详细信息,请参见卷的简短语法: https:// docs .docker.com / compose / compose-file /#short-syntax-3

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

这篇关于错误:在文件'.\docker-compose.yml'中,卷必须是映射,而不是字符串。 -带有Wordpress的Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆