0

I have an existing project with a docker-compose.yml file that runs a zookeeper and kafka image. How do I specify that the docker-compose.yml file needs to be loaded in my devcontainer.json?

Would it be possible to not modify the docker-compose file since others are using the same file, but not using VS Code. The docker-compose.yml looks like this.

---
version: '1'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:latest
    environment:
      xxxxx
    expose:
     xxxxx
     
  kafka:
    image: confluentinc/cp-kafka:latest
    depends_on:
      - zookeeper
    environment:
        xxxxx
    expose:
      xxxxx

  

Thanks!

Pepper
  • 109
  • 1
  • 7
  • use `"dockerComposeFile": "./path/to/docker-compose.yml",` the container you enter into should not exit, adding `command: sleep infinity` to compose is the fix – Lawrence Cherone Jul 15 '20 at 23:35
  • oh your need add `"shutdownAction": "stopCompose",` too – Lawrence Cherone Jul 15 '20 at 23:36
  • Thanks for the quick response Lawrence.
    My .devcontain.json looks like this:
    ` { "name": "setup_sys", "dockerComposeFile": "docker-compose.yml", "postCreateCommand": "sleep infinity", "shutdownAction": "stopCompose", } `
    The docker-compose.yml is in the same folder. When I try loading it in a container, I get the following ``` Service 'undefined' configured in devcontainer.json not found in Docker Compose configuration. ```
    – Pepper Jul 15 '20 at 23:49
  • add `"service": "zookeeper",` or whichever one you want to enter into – Lawrence Cherone Jul 15 '20 at 23:51
  • Do I need to create multiple "service" keys? One for each service in the docker-compose.yml? And do I need to add also the command sleep infinity, under what key would I add that? I presumed postCreateCommand, but not sure – Pepper Jul 15 '20 at 23:55
  • vs-code only enters into the one container, yeah you want to prevent the container stopping. - my use case is mount the app/development/codebase and compose in the other services – Lawrence Cherone Jul 16 '20 at 00:03
  • So, I can start all the containers and add a ubuntu image so that I can enter that. But I need all of them to not stop right? So, do I do the sleep infinity command for each of the containers? How do I specify that I want that command executed on each of the containers? Thanks again! – Pepper Jul 16 '20 at 00:07
  • that should really be in/part of the `docker-compose.yml` with other options. `.devcontainer.json` is for mounting the editor into a specific container – Lawrence Cherone Jul 16 '20 at 00:13

0 Answers0