This below start up script doesn't result in Kafka containers running when I check using "docker ps -a".
#!/bin/bash
sudo apt update
sudo apt install -y docker.io
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo git clone https://github.com/XXXXX/Nodejs_Kafka.git /home/XXXX/app
sudo mv /home/XXXXX/app/docker-compose.yml /home/XXXXXXX/docker-compose.yml
sudo cd /home/XXXXXX
sudo docker-compose up -d
I tried using a nodejs client library and then using it to create a GCP VM giving all the necessary details and in the metadata section I gave this script. I cloned a repo to get a docker-compose file and moved to home directory. But whenever I login to the vm by ssh and then try to see the containers by giving "docker ps -a" , no containers are ever created , which means the docker compose never ran.
As @Puteri mentioned, if executed on bash one by one after ssh, it 100 % works.