I am using devcontainers for a project in vscode with WSL, since yesterday I got an error that doesn’t let met to start the devcontainers.
The error in log shows that when trying to get the content of file product.json:
[2024-05-04T04:45:06.972Z] Start: Run in container: cat '/home/vscode/.vscode-server/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/product.json'
[2024-05-04T04:45:06.975Z] Stop (3 ms): Run in container: cat '/home/vscode/.vscode-server/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/product.json'
[2024-05-04T04:45:06.981Z] SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Kz (c:Usersjuanp.vscodeextensionsms-vscode-remote.remote-containers-0.362.0distextensionextension.js:225:1273)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Oue (c:Usersjuanp.vscodeextensionsms-vscode-remote.remote-containers-0.362.0distextensionextension.js:221:4028)
at async Nl (c:Usersjuanp.vscodeextensionsms-vscode-remote.remote-containers-0.362.0distextensionextension.js:201:4302)
at async bpe (c:Usersjuanp.vscodeextensionsms-vscode-remote.remote-containers-0.362.0distextensionextension.js:275:6649)
at async MN (c:Usersjuanp.vscodeextensionsms-vscode-remote.remote-containers-0.362.0distextensionextension.js:278:5396)
The file ‘product.json’ in container is empty which is causing the error
In docker-compose.yml file i have the devcontainers, PostgreSQL, and rabbitmq services:
version: '3'
services:
backend:
container_name: backend
image: mcr.microsoft.com/devcontainers/python:1-3.9-bullseye
volumes:
- .:/workspace:cached
# Other configuration options for the Python container
command: sleep infinity
links:
- frontend
environment:
- TZ=Etc/GMT-5
networks:
- mnet
frontend:
container_name: frontend
image: mcr.microsoft.com/devcontainers/typescript-node:0-14
volumes:
- .:/workspace:cached
# Other configuration options for the TypeScript container
command: sleep infinity
environment:
- TZ=Etc/GMT-5
networks:
- mnet
postgres-db:
container_name: postgres-db
image: postgres:16
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=dbpwd
- POSTGRES_DB=mydb
networks:
- mnet
ports:
- 5432:5432
rabbitmq:
container_name: rabbitmq
image: rabbitmq:3.9
volumes:
- rabbitmq-data:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=radmin
- RABBITMQ_DEFAULT_PASS=rpassword
ports:
- 5672:5672
- 15672:15672
networks:
- mnet
volumes:
db-data:
rabbitmq-data:
networks:
mnet:
driver: bridge
There is a folder called .devcontainer and inside there is two folders, one called backcontainer which has the devcontainer.json file, the same with the other folder called frontcontainer.
backcontainer/devcontainer.json
{
"name": "Backend",
"dockerComposeFile": ["../../docker-compose.yml"],
"service": "backend",
"shutdownAction": "none",
"workspaceFolder": "/workspace/backend"
}
frontcontainer/devcontainer.json
{
"name": "Frontend",
"dockerComposeFile": ["../../docker-compose.yml"],
"service": "frontend",
"shutdownAction": "none",
"workspaceFolder": "/workspace/frontend"
}
I tried rebuilding the containers backend and frontend ,also deleting that containers but i got the same result.
I have another project with devcontainers and is working fine, but in this case i don’t know what else to modify.