docker 启动devcontainer时包含错误

hsvhsicv  于 2023-02-03  发布在  Docker
关注(0)|答案(3)|浏览(188)

我有一个devcontainer。并且decontainer正在运行。但是如果我尝试做remote-cointainers %:重建容器。
然后我得到这个错误:

ERROR: Encountered errors while bringing up the project.
[17212 ms] Error: Command failed: docker-compose --project-name webscraper_devcontainer -f c:\xampp\htdocs\webScraper\.devcontainer\docker-compose.yml -f c:\Users\engel\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-containers\data\docker-compose\docker-compose.devcontainer.containerFeatures-1652959425107.yml up -d
[17212 ms]     at CR (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:187:618)
[17212 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[17212 ms]     at async ER (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:183:2075)
[17212 ms]     at async $R (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:226:2178)
[17213 ms]     at async Zy (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:226:3112)
[17213 ms]     at async BR (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:226:12448)
[17213 ms]     at async qR (c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js:226:12204)
[17224 ms] Exit code 1
[17227 ms] Command failed: C:\Users\engel\AppData\Local\Programs\Microsoft VS Code\Code.exe c:\Users\engel\.vscode\extensions\ms-vscode-remote.remote-containers-0.234.0\dist\spec-node\devContainersSpecCLI.js up --user-data-folder c:\Users\engel\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-containers\data --container-data-folder .vscode-server/data/Machine --container-system-data-folder /var/vscode-server --workspace-folder c:\xampp\htdocs\webScraper --workspace-mount-consistency cached --id-label vsch.local.folder=c:\xampp\htdocs\webScraper --id-label vsch.quality=stable --log-level debug --log-format json --config c:\xampp\htdocs\webScraper\.devcontainer\devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[17227 ms] Exit code 1

这是我的dockerfile的样子:

FROM php:8.1-apache as dev

ENV DEBIAN_FRONTEND=noninteractive
ENV APP_ENV=development

WORKDIR /var/www/html

RUN apt-get update \
  && apt-get -y install --no-install-recommends apt-utils zip unzip nano ncdu 2>&1 \
    && apt-get -y install --no-install-recommends python graphviz 2>&1 \
  && apt-get -y install git iproute2 procps lsb-release \
  && apt-get install -y -qq software-properties-common \
  && apt-get install -y -qq wget git lynx ack-grep \
  && yes | pecl install xdebug \
  && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && apt-get -y install libicu-dev \
    && docker-php-ext-install intl pdo_mysql opcache \
    && pecl install apcu && docker-php-ext-enable apcu \
    && echo "apc.enable_cli=1" > /usr/local/etc/php/php.ini \
    && echo "apc.enable=1" > /usr/local/etc/php/php.ini \
  && echo "post_max_size = 100M" > /usr/local/etc/php/php.ini \
    && a2enmod rewrite \
  && apt-get autoremove -y \
  && apt-get clean -y \
  && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install gnupg2 -y

RUN rm -rf /etc/apache2/sites-enabled \
    && ln -s /var/www/html/.devcontainer/sites-enabled /etc/apache2/sites-enabled

RUN echo 'alias ll="ls -la --color=auto"' >> ~/.bashrc && \
    echo "alias ack='ack-grep'" >> ~/.bashrc

RUN chown www-data:www-data -R ./

ENV DEBIAN_FRONTEND=dialog

和我的docker-compose. yml:

version: '3'
services:
  web:
    container_name: dockeryii
    build:
      context: ..
      dockerfile: dockerfile
      target: dev
    volumes:
      - ../:/var/www/html       
    command: /bin/sh -c "service apache2 start && while sleep 1000; do :; done"
  db:
    container_name: dockeryiimysql
    image: mysql:latest
    volumes:
      - dockeryiimysql:/var/lib/mysql
    expose:
      - 3306
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
      MYSQL_DATABASE: sdi      
  phpmyadmin:  
    container_name: dockeryiipma
    image: phpmyadmin:latest
    environment:
      UPLOAD_LIMIT: 300M
      PMA_ARBITRARY: 1
      APACHE_HTTP_PORT_NUMBER: 8080
    ports:
      - 8080:8080
    command: /bin/bash -c "sed -i \"s/80/$$APACHE_HTTP_PORT_NUMBER/g\" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && /docker-entrypoint.sh apache2-foreground"

volumes:
  dockeryiimysql: {}

和我的开发容器json:

{
  "name": "Dockeryii",
  "dockerComposeFile": ["docker-compose.yml"],
  "service": "web",
  "shutdownAction": "none",
  "extensions": ["felixfbecker.php-debug",
        "zobo.php-intellisense",
        "mrmlnc.vscode-apache"],
  "forwardPorts": [80],
  "workspaceFolder": "/var/www/html",
  "settings": { 
        "php.validate.executablePath": "/usr/local/bin/php"
    }
}

所以我的问题是:我要改变什么?
谢谢
如果我这样做:

docker-compose -f C:\xampp\htdocs\webScraper\.devcontainer\docker-compose.yml config

我只得到de file的输出:docker-compose.yml.

tkclm6bt

tkclm6bt1#

  • docker-compose -f /path/to/docker-compose.yml config仅验证和查看合成文件。
  • 尝试手动构建和运行容器(不使用vscode的devcontainer)以检查每个Dockerfile是否有效,因为您的docker-compose.yml在语法上有效并受支持
  • 另外,这里是有关排除devconainter故障的vscode提示
relj7zay

relj7zay2#

好吧。对我有用的是:

docker-compose down

然后在VS代码中,它工作了。

mfpqipee

mfpqipee3#

用于更改CLI上下文的Docker上下文有问题。您可以删除其他上下文,但保留本地上下文,或者直接删除路径为~/.docker/contexts/meta/fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e/meta.json的meta.json文件

相关问题