skip to Main Content

I vs code I have a devcontainer. And de containers are running. But if I try to do remote-cointainers%:Rebuild container.

Then I get this errors:

ERROR: Encountered errors while bringing up the project.
[17212 ms] Error: Command failed: docker-compose --project-name webscraper_devcontainer -f c:xampphtdocswebScraper.devcontainerdocker-compose.yml -f c:UsersengelAppDataRoamingCodeUserglobalStoragems-vscode-remote.remote-containersdatadocker-composedocker-compose.devcontainer.containerFeatures-1652959425107.yml up -d
[17212 ms]     at CR (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:187:618)
[17212 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[17212 ms]     at async ER (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:183:2075)
[17212 ms]     at async $R (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:226:2178)
[17213 ms]     at async Zy (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:226:3112)
[17213 ms]     at async BR (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:226:12448)
[17213 ms]     at async qR (c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js:226:12204)
[17224 ms] Exit code 1
[17227 ms] Command failed: C:UsersengelAppDataLocalProgramsMicrosoft VS CodeCode.exe c:Usersengel.vscodeextensionsms-vscode-remote.remote-containers-0.234.0distspec-nodedevContainersSpecCLI.js up --user-data-folder c:UsersengelAppDataRoamingCodeUserglobalStoragems-vscode-remote.remote-containersdata --container-data-folder .vscode-server/data/Machine --container-system-data-folder /var/vscode-server --workspace-folder c:xampphtdocswebScraper --workspace-mount-consistency cached --id-label vsch.local.folder=c:xampphtdocswebScraper --id-label vsch.quality=stable --log-level debug --log-format json --config c:xampphtdocswebScraper.devcontainerdevcontainer.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

And this is how my dockerfile looks like:

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



and my 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: {}

and my devcontainer.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"
    }
}

So my question is: What I have to change?

Thank you

if I do this:

docker-compose -f C:xampphtdocswebScraper.devcontainerdocker-compose.yml config

I just get the output of de file: docker-compose.yml.

3

Answers


  1. Chosen as BEST ANSWER

    Oke. What workded for me was:

    docker-compose down
    

    And then in vs code it worked.


    • docker-compose -f /path/to/docker-compose.yml config only validate and view the Compose file.
    • Try to building and running your containers manually (without vscode’s devcontainer) to check if every Dockerfile are valid as your docker-compose.yml is syntactically valid and supported
    • Else here is vscode tips about troubleshooting devconainter
    Login or Signup to reply.
  2. Something is wrong with your docker context which is used for changing CLI context. you can remove other contexts but keep the local one, or remove meta.json file directly which can be located at path like ~/.docker/contexts/meta/fe9c6bd7a66301f49ca9b6a70b217107cd1284598bfc254700c989b916da791e/meta.json

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search