1

I am trying install the docker/compose-bin plugin on a Google Cloud VM with Container Optimized OS (https://hub.docker.com/r/docker/compose-bin/tags).

Has anybody achieved this?

I understand docker is running as a container and I think I have to install the plugin binary in the respective plugins folder inside the container. Am I in the right direction?

I am able to use the old docker-compose (https://hub.docker.com/r/docker/compose/tags) in a container using this script and alias:

#!/bin/bash
VERSION=${1:-1.27.4}

echo "* Add an alias for docker-compose to the shell configuration file ..."
echo alias docker-compose="'"'docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$PWD:$PWD" \
    -w="$PWD" \
    docker/compose:'"${VERSION}"''"'" >> ~/.bashrc

echo "* Pull container image for docker-compose ..."
docker pull docker/compose:${VERSION}

echo "* Done"
echo "* To use docker-compose, run 'source ~/.bashrc' or simply re-login"

taken from https://gist.github.com/kurokobo/25e41503eb060fee8d8bec1dd859eff3

But I would really like to use the new plugin.

supercoco
  • 141
  • 5
  • What is the problem you are trying to solve? `Has anybody achieved this?` is not a problem statement. – John Hanley May 19 '23 at 01:35
  • I am trying to install the docker/compose-bin plugin on a Google Cloud VM with Container Optimized OS. Don't know how to do it. – supercoco May 19 '23 at 01:56
  • Hi @supercoco, the documents listed below may be of assistance 1) https://gist.github.com/kurokobo/25e41503eb060fee8d8bec1dd859eff3 2) https://medium.com/@kyle.powers103/installing-docker-on-gcloud-vms-1479dd9dde30 – Murali Sankarbanda May 19 '23 at 12:43

1 Answers1

2

OK I was not in the right track. Docker compose is not a server plugin but a client plugin. So you just need it on your ~/.docker.

In COS (Container Optimized OS) the /var/lib/docker directory is writable and persistent so you can save the binaries there and create a symbolic link for every user that wants to use it.

These are the instructions that worked flawlessly:

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
CLI_PLUGINS=/var/lib/docker/cli-plugins
mkdir -p $DOCKER_CONFIG
sudo mkdir -p $CLI_PLUGINS
sudo curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o $CLI_PLUGINS/docker-compose
sudo chmod -R 755 /var/lib/docker
ln -s $CLI_PLUGINS $DOCKER_CONFIG/cli-plugins 

Thanks to https://github.com/docker/compose/issues/10463

Other users on the same machine would have to run:

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
CLI_PLUGINS=/var/lib/docker/cli-plugins
mkdir -p $DOCKER_CONFIG
ln -s $CLI_PLUGINS $DOCKER_CONFIG/cli-plugins 
supercoco
  • 141
  • 5
  • almost flawlessly, this permission change won't persist ```sudo chmod -R 755 /var/lib/docker``` so you will have to add it to a cloud_init script or add specific users to a group in order to be able have permission to execute the binary file – supercoco May 19 '23 at 21:17