Allan Barcelos
Allan Barcelos

Reputation: 51

Docker VS code remove devcontainer

Every time when I try open my code in a devcontainer I receive this error:

[2020-04-12T17:35:08.489Z] [PID 4968] [22748 ms] Start: Run: docker ps -q -a --filter label=com.docker.compose.project=nodejs-express-jwt_devcontainer --filter label=com.docker.compose.service=api [2020-04-12T17:35:08.591Z] [PID 4968] [22850 ms] Start: Run: docker inspect --type container ad270338d286 [2020-04-12T17:35:10.986Z] [PID 4968] [25245 ms] Start: Inspecting container [2020-04-12T17:35:10.986Z] [PID 4968] [25245 ms] Start: Run: docker inspect --type container ad270338d286ba6db0560a94fd7a826bb563f17299799bfc1b8488becea02091 [2020-04-12T17:35:14.884Z] [PID 4968] [29143 ms] Start: Run: docker exec -i -u node -e VSCODE_REMOTE_CONTAINERS_SESSION=6351885a-14c9-4520-8ac6-db1d1e4218231586712884962 ad270338d286ba6db0560a94fd7a826bb563f17299799bfc1b8488becea02091 /bin/sh [2020-04-12T17:35:14.899Z] [PID 4968] [29158 ms] Start: Run in container: uname -m [2020-04-12T17:35:27.282Z] [PID 4968] [41541 ms] Start: Run in container: cat /etc/passwd [2020-04-12T17:35:27.282Z] [PID 4968] [41541 ms] Stdin closed! [2020-04-12T17:35:27.285Z] [PID 4968] [41544 ms] Shell server terminated (code: 1, signal: null) No such exec instance: 43330c7272221ead535677993be73423b5f6bdb8497429ee7380a81bb43bce59

I have this files in my .devcontainer

Docker file

FROM node:12.16-alpine

#Linux setup
RUN apk update \
  && apk add --update alpine-sdk \
  && apk add --no-cache git \
  && apk add --no-cache npm \
  && npm cache verify
  # && sed -i -e "s/bin\/ash/bin\/sh/" /etc/passwd

RUN git config --global user.email "[email protected]" \
    && git config --global user.name "My Name"

docker-composer.yml

version: '3.3'

services:
    api:
        build: .
        restart: always
        depends_on: 
            - db
        ports: 
            - 3000:80
        environment: 
            DB_HOST: db
            DB_USER: apiuser
            DB_PASSWORD: apipass
            DB_NAME: apidb
        # volumes: 
        #     - ./src:/var/www/html/wp-content/plugins/meu-plugin

    db:
        image: mysql:5.7
        restart: always
        environment: 
            MYSQL_DATABASE: apidb
            MYSQL_USER: apiuser
            MYSQL_PASSWORD: apipass
            MYSQL_RANDOM_ROOT_PASSWORD: '1'
        volumes: 
            - db:/var/lib/mysql

    adminer:
        depends_on: 
            - db
        image: adminer
        restart: always
        ports: 
            - 8888:8080

networks: 
    back:

volumes: 
    db:

devcontainer.json

{
    "name": "Node.js",
    // "dockerFile": "Dockerfile",
    "service": "api",
    "dockerComposeFile": "docker-compose.yml",

    // Use 'appPort' to create a container with published ports. If the port isn't working, be sure
    // your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
    "appPort": [3000],

    // Comment out the next line to run as root instead.
    "remoteUser": "node",

    // Use 'settings' to set *default* container specific settings.json values on container create. 
    // You can edit these settings after create using File > Preferences > Settings > Remote.
    "settings": {
        "terminal.integrated.shell.linux": "/bin/sh"
    },

    // Specifies a command that should be run after the container has been created.
    // "postCreateCommand": "yarn install",

    // Add the IDs of extensions you want installed when the container is created in the array below.
    "extensions": [
        "dbaeumer.vscode-eslint"
    ]

}

I dont know why this not work ...

Upvotes: 5

Views: 7726

Answers (2)

Han
Han

Reputation: 167

you say docker-composer.yml. Is that the name of your file, then it probably should be docker-compose.yml.

Upvotes: 1

leiropi
leiropi

Reputation: 474

I think the problem might be that your api container is terminating after running the git config commands. Did you try to add

command: sleep infinity

to the api service in your docker-compose.yml?

Upvotes: 2

Related Questions