Setting up a Docker dev container in VS Code with a FrankenPHP service depending on a Memcached and a Postgres service, I get to the point of the Memcached and Postgres services up and running, and the main App service dumps with an error or two.
Docker log with the error sequence:
✔ Container newseeds_devcontainer-db-1 Running 0.0s
✔ Container newseeds_devcontainer-cache-1 Running 0.0s
✔ Container newseeds_devcontainer-app-1 Started 0.0s
[1292 ms] Start: Run: docker ps -q -a --filter label=com.docker.compose.project=newseeds_devcontainer --filter label=com.docker.compose.service=app
[1330 ms] Start: Run: docker inspect --type container 38bd8826df6d
[1442 ms] Start: Inspecting container
[1442 ms] Start: Run: docker inspect --type container 38bd8826df6d56722aa2b2b25d8f082630e1f7c2043e9c722135edd839838a7f
[1473 ms] Start: Run in container: /bin/sh
[1474 ms] Start: Run in container: uname -m
[1505 ms] Shell server terminated (code: 1, signal: null)
[1505 ms] Error response from daemon: container 38bd8826df6d56722aa2b2b25d8f082630e1f7c2043e9c722135edd839838a7f is not running
[1505 ms] Start: Run in container: (command -v getent >/dev/null 2>&1 && getent passwd 'root' || grep -E '^root|^[^:]*:[^:]*:root:' /etc/passwd || true)
[1505 ms] Stdin closed!
[1505 ms] Error: An error occurred setting up the container.
[1505 ms] at CtA (/Users/fpolli/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:409:3709)
[1505 ms] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[1505 ms] at async UtA (/Users/fpolli/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:481:3865)
[1505 ms] at async $C (/Users/fpolli/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:481:4807)
[1505 ms] at async QrA (/Users/fpolli/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:661:13255)
[1505 ms] at async urA (/Users/fpolli/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:661:12996)
[1507 ms] Exit code 1
Below are the docker-compose file, the dockerfile for the app container, and the devcontainers.json:
docker-compose:
services:
app:
build:
context: .
entrypoint: php artisan octane:frankenphp --max-requests=1
ports:
- "80:8000"
- "443:443"
depends_on:
- db
- cache
volumes:
- storage://D/www/laravel-projects/newseeds/storage
command: sleep infinity,
networks:
- storefront
- backroom
db:
image: postgres:latest
restart: unless-stopped
volumes:
- data://D/PostgreSQL/data
environment:
POSTGRES_USER: theuser
POSTGRES_DB: arandomname
POSTGRES_PASSWORD: "very ultra secret"
networks:
- backroom
cache:
image: memcached:latest
restart: unless-stopped
#volumes:
networks:
- backroom
networks:
storefront:
backroom:
volumes:
data:
storage:
Dockerfile:
FROM dunglas/frankenphp
RUN install-php-extensions pcntl
COPY . /app
ENTRYPOINT ["php", "artisan", "octane:frankenphp"]
devcontainer.json
"name": "the name",
"dockerComposeFile": "./docker-compose.yaml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "lts",
"nvmVersion": "latest"
},
},
"forwardPorts": [
5432
],
//"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"onecentlin.laravel5-snippets"
]
}
}
}
Note that I develop on a Windows 11 PC desktop and a MacBook, and on the PC the "remoteUser" line needs to be active in order for the devcontainer.json file to be read, and on the MacBook, it needs to be commented out. I wrote this on the MacBook, hence the commenting. The outcome is the same on both computers.
Thank you.
Your docker container terminates by itself
[1505 ms] Error response from daemon: container 38bd8826df6d56722aa2b2b25d8f082630e1f7c2043e9c722135edd839838a7f is not running
The reason is unknown but can be anything (error or regular termination). But clearly VSCode cannot continue connecting to the container when it exited.
Consider setting "command: sleep infinity" in the docker compose or "CMD sleep infinity" in the Dockerfile. Then start the application manually (or within VSCode)
I think in your case the reason is that your entrypoint is not a shell and hence "command sleep infinity" is not working.