Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

docker - docker services.web.working_dir包含无效类型,应为字符串(docker services.web.working_dir contains an invalid type, it should be a string)

I am trying to up phpserver via docker-compose.

(我正在尝试通过docker-compose来启动phpserver。)

I put 3 files in my working directory.

(我在工作目录中放入了3个文件。)

.env docker-compose.yml Dockerfile

(.env docker-compose.yml Dockerfile)

.env

(.env)

##PATHS

DB_PATH_HOST=./databases
APP_PATH_HOST=./blog
APP_PATH_CONTAINER=/var/www/html/
MYSQL_ROOT_PASSWORD=123456

docker-compose.yml

(docker-compose.yml)

version: '3'

(版本:“ 3”)

services:
  web:
    build: .
    environment:
      - APACHE_RUN_USER=www-data
    volumes:
      - ${APP_PATH_HOST}: ${APP_PATH_CONTAINER}
    ports:
      - 8080:80
    working_dir:
      - ${APP_PATH_CONTAINER}
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - ${DB_PATH_HOST}: /var/lib/mysql

  adminer:
    image: adminer
    restart: always
    ports:
      - 6080:8080
  composer:
    image: composer:1.7
    volumes:
      - ${APP_PATH_HOST}: ${APP_PATH_CONTAINER}
    working_dir: ${APP_PATH_CONTAINER}
    command: composer install

and Dockerfile

(和Dockerfile)

FROM php:7.2-apache

RUN docker-php-ext-install 
     pdo_mysql 
     && a2enmod
     rewrite

But after I try to run

(但是在我尝试跑步之后)

docker-compose up --build

I have the problem

(我有问题)

ERROR: The Compose file '.docker-compose.yml' is invalid because:
services.web.working_dir contains an invalid type, it should be a string
services.composer.volumes contains an invalid type, it should be a string
services.web.volumes contains an invalid type, it should be a string
services.db.volumes contains an invalid type, it should be a string

I tried to change docker-compose file version to 2 - does not work I tried to use '' and "" the same problem.

(我试图将docker-compose文件版本更改为2-不起作用,我尝试使用“和”相同的问题。)

I want to run my server successfully.

(我想成功运行服务器。)

  ask by Виктор Васильев translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
version: "3.3"

services:
  web:
    build: .
    environment:
      - APACHE_RUN_USER=www-data
    volumes:
      - "${APP_PATH_HOST}: ${APP_PATH_CONTAINER}"
    ports:
      - 8080:80
    working_dir: ${APP_PATH_CONTAINER}
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - "${DB_PATH_HOST}:/var/lib/mysql"

  adminer:
    image: adminer
    restart: always
    ports:
      - 6080:8080
  composer:
    image: composer:1.7
    volumes:
      - "${APP_PATH_HOST}: ${APP_PATH_CONTAINER}"
    working_dir: ${APP_PATH_CONTAINER}
    command: composer install

What you used for working_dir was a list.

(您用于working_dir的是一个列表。)

It needed a string.

(它需要一个字符串。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...