Help Needed for local setup of the project using docker

Hello everyone I am trying to locally setup the project in windows WSL +docker i have now set up the cht-layout project (dev container) (ig this this a temple of a real application) . After that what i understood from the ( App Developer Hosting in CHT 4.x | Community Health Toolkit) that I have:

to clone the cht-core repo and run the docker command ./cht-docker-compose.sh (in the dev conainer ?)
but facing this error can some one please help me guide what i need to do to resolve this

node@dcb0810ab35f:/workspaces/cht-project/cht-core/cht-core/scripts$ cd ..
node@dcb0810ab35f:/workspaces/cht-project/cht-core/cht-core$ ./cht-docker-compose.sh up -d
bash: ./cht-docker-compose.sh: No such file or directory
node@dcb0810ab35f:/workspaces/cht-project/cht-core/cht-core$ ///

thank you in advance

hi @Shubhank - thanks so much for your question and welcome to the forum! This is exactly the right place to ask your question. Let’s try and solve your issue!

It looks like your WSL2 VM has the CHT Core repo cloned, but let’s be sure you’re up to date first. I’m assuming that /workspaces/cht-project/cht-core/cht-core is where the CHT Core repo is cloned to. To update it:

  1. launch your wsl2 terminal
  2. Change directories into the CHT Core: cd /workspaces/cht-project/cht-core/cht-core
  3. Tell git to fetch and meta data and then to pull down any updates: git fetch ; git pull origin

Report back if you get an errors from that. It’s best if you can copy and past from the WSL2 terminal instead of taking a screenshot. Here’s what it looked like for me as user mrjones on my WSL2 host named wsl2 with a directory structure that matches yours:

mrjones@wsl2:~$ cd /workspaces/cht-project/cht-core/cht-core/                                           mrjones@wsl2:/workspaces/cht-project/cht-core/cht-core$ git fetch ; git pull origin                     Already up to date. 

Now that we’re sure the code is up to date, let’s see if you can run the Docker Helper:

  1. launch your wsl2 terminal
  2. Change directories into the CHT Core’s Docker Helper directory: cd cd /workspaces/cht-project/cht-core/cht-core/scripts/docker-helper-4.x/
  3. Try calling docker helper: ./cht-docker-compose.sh

If everything is working, and you have docker desktop already installed, you should see it start to download the upgrade service container:

mrjones@wsl2:~$ cd /workspaces/cht-project/cht-core/cht-core/scripts/docker-helper-4.x/
mrjones@wsl2:/workspaces/cht-project/cht-core/cht-core/scripts/docker-helper-4.x$ ./cht-docker-compose.sh
No project found, follow the prompts to create a project .env file.

Would you like to initialize a new project [y/N]? y

Do you want to run the latest CHT Core version (4.18.0) [Y/n]?

How do you want to name the project? first post FTW

Downloading compose files ... done
homedir: /home/mrjones/.medic/cht-docker/first_post_ftw-dir
[+] Running 5/8                                                                                                          
⠙ cht-upgrade-service [⣿⣿⣤⣤⣿⣿⣿] 73.93MB / 127.5MB Pulling                                                        13.1s    ✔                       

And then, depending on the speed of your computer and your internet connection, you should eventually get the URL of your local CHT instance:

 --------------------------------------------------------
Success! "first_post_ftw" is set up:

	https://172-24-54-83.local-ip.medicmobile.org:10443/ (CHT)
	https://172-24-54-83.local-ip.medicmobile.org:10443/_utils (Fauxton)

	Login: medic
	Password: password

--------------------------------------------------------
Start existing project
   ./cht-docker-compose.sh ENV-FILE.env
Stop and keep project:
	./cht-docker-compose.sh ENV-FILE.env stop
Stop and destroy all project data:
	./cht-docker-compose.sh ENV-FILE.env destroy

https://docs.communityhealthtoolkit.org/hosting/4.x/app-developer/

  Have a great day!

Here is a screen shot showing:

  1. upper left side: the WSL2 terminal having run the Docker Helper and showing the URL
  2. right site: Docker Desktop in Windows showing all the CHT services running
  3. lower left side: a browser showing the CHT login being served from my local instance

2 Likes

Thank you very much for such detailed explanation what I understood I need to navigate to exact location to run command but now I ran into issue that I dont have docker

node@bfb150a064ec:/workspaces/cht-project/cht-core/cht-core/scripts/docker-helper-4.x$ ./cht-docker-compose.sh

“docker” or “docker compose” is not installed or could not be found. Please install and try again!

but i have docker in my machine

C:\Users\Shubhank>docker --version
Docker version 27.3.1, build ce12230 

how do i give access from dev container to host docker

I modified the .devcontaier.json file as ChatGPT said but it still failed

{
  "name": "CHT Dev",
  "image": "medicmobile/cht-app-ide:latest",

  // Required for Puppeteer (browser automation in testing)
  "capAdd": ["SYS_ADMIN"],

  // Allow the DevContainer to use host Docker
  "mounts": [
    "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
  ]

  // (Optional but recommended) Install VS Code extensions
  
}

Can you please help

@Shubhank - to enable Docker Desktop inside WSL2, checkout this guide from Docker.

Let us know how it goes!

Also - I’d revert any changes to .devcontaier.json to ensure there’s no conflicts with what Docker Desktop expects.

Also 2x - If you get this dialog message when installing docker and then launching WSL2, you want to choose “Allow access”:

Hi @mrjones sorry for bugging you again but I still can’t set up the repo like i i have the dev container up running and i have selected the wsl 2 engine in docker still when i run the command inside the container its says:

bash node@bfb150a064ec:/workspaces/cht-project$ docker ps  
bash: docker: command not found 

Can you tell me what I need to learn or do to resolve such an issue?

Thank you

hello @diana if possible can you help me with this issue

Oh no - I’m sorry to hear that @Shubhank - that sounds really frustrating!

What version of windows are you running (eg 10 “Home” vs “11 Pro” etc)? What version of WSL are you running?

I was able to get the latter with wsl --version like this:

C:\Users\mrjones>wsl --version
WSL version: 2.4.13.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5716
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.19045.5737

oh thank you this is WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.5189 version I’m using

this is how my .devcontainer file looks like rn I have modified it a bit {
“name”: “CHT Dev”,
“image”: “medicmobile/cht-app-ide:latest”,

// Required for Puppeteer (browser automation in testing)
“capAdd”: [“SYS_ADMIN”],

// Allow the DevContainer to use host Docker
“mounts”: [
“source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind”
]

// (Optional but recommended) Install VS Code extensions
}

Thanks for the info @Shubhank . Since there’s a newer release of WSL2 AND you’re having issues with your release, I think it’d be good to re-install WSL2.

I found a great guide online which I’ve copied here with just the parts you need:

  1. In powershell (as admin)

    # list all installed distros
    wsl -l -v
    
    # destroy distros listed above - you likely just have Ubuntu
    wsl --unregister Ubuntu
    wsl --unregister Debian # and so on
    
  2. In Settings > Apps > Apps & Features

  • search for Ubuntu (then Debian, etc), and if something is found, click on uninstall
  • search for Linux, and if something is found, click on uninstall on all results
  1. In Start Menu > Turn Windows Features on or off
  • Untick Virtual Machine Platform checkbox
  • Untick Windows Subsystem for Linux checkbox
  1. Reboot

  2. Installing wsl - In powershell (as admin)

    # install wsl
    wsl --install
    
  1. Reboot and wait for the Ubundu installation to complete and ask for username (it might takes some time).

Hey @Shubhank it will be much easier to work with GitHub codespaces setting up this project, it offers reasonable amount of time even for free users, just setup a github codespace for this project and follow this LOCAL SETUP.

When I get this error in WSL, it’s usually when Docker Desktop is not running on Windows, or the WSL integration is disabled.

Please make sure that the WSL integration is enabled for your default and any additional Linux distros:

Thank you @binod but I guess I have my docker desktop up and running this is what i get when i do docker ps in command prompt

C:\Users\Shubhank>docker ps
CONTAINER ID   IMAGE                            COMMAND                  CREATED      STATUS        PORTS     NAMES
bfb150a064ec   medicmobile/cht-app-ide:latest   "/bin/sh -c 'echo Co…"   5 days ago   Up 12 hours             vibrant_leakey

and I have the wsl 2 integration selected
Is there anything I could have done wrong while cloning/or setting up the docker container I followed this Getting started building a CHT app | Community Health Toolkit

Oh Thank you @shashi_sah will try this if I still does not work :))

If you are still willing to try running docker in a WSL distro, here are some troubleshooting steps that I sourced from here and here:

  1. Check the output of wsl -l (from Windows CMD or PowerShell)
  2. If docker-desktop is missing in the list, uninstall and reinstall Docker Desktop (latest version)
  3. Check wsl -l again
  4. If docker-desktop is now available, check if docker command is recognized in WSL
  5. Restart and try the above step #4

Please check this comment too.

Thanks a lot @binod for this this pointer, I was finally able to setup cht-core on my Windows machine because of this!

A mistake I made was exporting the COUCH variables in ~/.profile, which is sourced only by login shells.
(I use bash as my default shell)

Some notes which might be useful for future contributors:

When you enter the shell using:

wsl -d <distro>

WSL launches a non-login shell, so ~/.profile is skipped.

  • If you’re using bash, put the variables in ~/.bashrc.
  • If you’re on zsh, note that zsh defaults to a login shell when launched using the command above, so ~/.zprofile is sourced automatically.

After moving the exports to the appropriate startup file (~/.bashrc in my case), everything works as expected.

I found this thread quite insightful while debugging this.
See this to check whether the current shell is a login shell.

Thanks.

3 Likes

@apoorvapendse - yay - so glad to hear you’re unblocked! Thanks for posting great follow up message summarizing the tips you followed. Very much appreciated!

2 Likes