每次我尝试在devcontainer中打开代码时,都会收到以下错误:
〔2020-04-12T17:35:08.489Z〕〔PID 4968〕〔22748毫秒〕开始:运行:docker ps-q-a--filter label=com.doker.compose.project=nodejs-express-jwt_devcontainer--filter label=com.docker.compose.service=api[2020-04-12T17:35:08.591Z][PID 4968][22850ms]开始:运行:docker检验——型集装箱ad270338d286〔2020-04-12T17:35:10.986Z〕〔PID4968][25245 ms]开始:检查容器[2020-04-12T17:35:10.986Z][PID 4968][25245 ms]开始:运行:docker检验型集装箱ad270338d286ba6db0560a94fd7a826bb563f17299799bfc1b8488ecea02091【2020-04-12T17:35:14.884Z】【PID 4968】【29143毫秒】开始:运行:dockerexec-i-u节点-eVSCODE_REMOTE_CONTAINERS_SESSION=6351885a-14c9-4520-8ac6-db1d1e418231586712884962ad270338d286ba6db0560a94fd7a826bb563f17299799bfc1b8488ecea02091/bin/sh【2020-04-12T17:35:14.899Z】【PID 4968】【29158 ms】启动:磨合容器:uname-m〔2020-04-12T17:35:27.282Z〕〔PID 4968〕〔41541毫秒〕开始:在容器中运行:cat/etc/passwd〔2020-04-12T17:35:27.282Z〕[PID 4968][41541 ms]Stdin关闭!【2020-04-12T17:35:27.285Z】【PID4968][41544 ms]外壳服务器已终止(代码:1,信号:null(否此类exec实例:43330c7272221ad535677993be73423b5f6bdb8497429ee7380a81bb43bce59
我的.devcontainer 中有这些文件
Docker文件
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 "my@email.com"
&& 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"
]
}
我不知道为什么这不起作用。。。
我认为问题可能是您的api容器在运行git-config命令后终止。你试着添加了吗
command: sleep infinity
到您的docker-compose.yml
中的api服务?
您说的是docker-composer.yml
。这是你的文件名吗?那么它可能应该是docker-compose.yml
。