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:


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.


2 Answers 2


The writable and executable mounts are:

  • /var/lib/{google,docker,toolbox} (stateful)
  • /var/lib/cloud (stateless, tmpfs, 2 MB)
  • /mnt/disks (stateless, tmpfs, 256 KB)

/var/lib/{google,docker,toolbox} seems like the best option, and /var/lib/google is better then /var/lib/docker because it has o+x (I suppose /var/lib/docker lacks o+x for a reason):

$ sudo curl -sSL \
  https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 \
  -o /var/lib/google/docker-compose
$ sudo chmod o+x /var/lib/google/docker-compose
$ mkdir -p ~/.docker/cli-plugins
$ ln -sf /var/lib/google/docker-compose \
$ docker compose version

the official installation instructions
where docker looks for plugins

Alternatively one can use the docker image:

  • using alias:


    if [ -f ~/.bashrc ]; then . ~/.bashrc; fi


    alias docker-compose='docker run --rm docker compose'
    $ docker-compose version
  • using a function:


    docker() {
        if [ "$1" = compose ]; then
            command docker run --rm docker "$@"
            command docker "$@"
    export -f docker
    $ docker compose version
  • using a script:


    #!/bin/sh -eu
    if [ "$1" = compose ]; then
        /usr/bin/docker run --rm docker "$@"
        /usr/bin/docker "$@"


    export PATH=/var/lib/google/bin:$PATH
    $ sudo chmod o+x /var/lib/google/bin/docker
    $ docker compose version

For the record, I also added the info to the mentioned issue.


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:

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:

ln -s $CLI_PLUGINS $DOCKER_CONFIG/cli-plugins 
  • 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
    Commented May 19, 2023 at 21:17
  • I'd strongly suggest against making every file in /var/lib/docker executable, or even adding o+x to /var/lib/docker. See my answer.
    – x-yuri
    Commented Dec 11, 2023 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .