devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
1.03k stars 263 forks source link

[javascript-node-postgres] Invalid docker image #112

Closed jgeurts closed 1 year ago

jgeurts commented 1 year ago

Hi,

I'm trying to get javascript-node-postgres working with codespaces, but container initialization is failing with the following message:

2023-01-26 00:17:22.182Z: Creating container...
2023-01-26 00:17:22.198Z: $ devcontainer up --id-label Type=codespaces --workspace-folder /var/lib/docker/codespacemount/workspace/postgres-pool --mount type=bind,source=/.codespaces/agent/mount/cache,target=/vscode --user-data-folder /var/lib/docker/codespacemount/.persistedshare --container-data-folder .vscode-remote/data/Machine --container-system-data-folder /var/vscode-remote --log-level trace --log-format json --update-remote-user-uid-default never --mount-workspace-git-root false --skip-non-blocking-commands --skip-post-create --expect-existing-container --config "/var/lib/docker/codespacemount/workspace/postgres-pool/.devcontainer/devcontainer.json" --override-config /root/.codespaces/shared/merged_devcontainer.json --default-user-env-probe loginInteractiveShell
2023-01-26 00:17:22.462Z: @devcontainers/cli 0.28.0. Node.js v14.21.2. linux 5.4.0-1100-azure x64.
2023-01-26 00:17:30.710Z: Error: The expected container does not exist.
2023-01-26 00:17:30.710Z:     at tie (/usr/lib/node_modules/@microsoft/vscode-dev-containers-cli/dist/spec-node/devContainersSpecCLI.js:1854:2097)
2023-01-26 00:17:30.710Z:     at processTicksAndRejections (internal/process/task_queues.js:95:5)
2023-01-26 00:17:30.711Z:     at async Fie (/usr/lib/node_modules/@microsoft/vscode-dev-containers-cli/dist/spec-node/devContainersSpecCLI.js:1921:2266)
2023-01-26 00:17:30.711Z:     at async $f (/usr/lib/node_modules/@microsoft/vscode-dev-containers-cli/dist/spec-node/devContainersSpecCLI.js:1921:3239)
2023-01-26 00:17:30.711Z: {"outcome":"error","message":"The expected container does not exist.","description":"The expected container does not exist."}
2023-01-26 00:17:30.727Z:     at async eoe (/usr/lib/node_modules/@microsoft/vscode-dev-containers-cli/dist/spec-node/devContainersSpecCLI.js:2045:17247)
2023-01-26 00:17:30.728Z:     at async Qse (/usr/lib/node_modules/@microsoft/vscode-dev-containers-cli/dist/spec-node/devContainersSpecCLI.js:2045:16993)
2023-01-26 00:17:30.728Z: devcontainer process exited with exit code 1

In my project, I have the following files:

devcontainer.json

{
  "name": "postgres-pool",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
  "customizations": {
    "vscode": {
      "extensions": [
        "EditorConfig.EditorConfig"
      ]
    }
  },
  "postCreateCommand": "npm install"
}

docker-compose.yml

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile

    volumes:
      - ../..:/workspaces:cached

    # Overrides default command so things don't shut down after the process ends.
    command: sleep infinity

    # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
    network_mode: service:db

    # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
    # (Adding the "ports" property to this file will not forward from a Codespace.)

  db:
    image: postgres:latest
    restart: unless-stopped
    volumes:
      - postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres

    # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
    # (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
  postgres-data:

Dockerfile

FROM mcr.microsoft.com/devcontainers/javascript-node:0-18

I've verified that the javascript-node image exists as well as the postgres image. Any advice would be appreciated!

jgeurts commented 1 year ago

haha, seems to have resolved itself 🤷