Home > Back-end >  Ubuntu - upgrading docker-compose version
Ubuntu - upgrading docker-compose version

Time:03-01

new to Docker so this may be basic, but after my googling I have still not found a solution

I have a docker-compose.yml file I am trying to run (version for the file is "3.4", but I am getting the error:

"The compose file is invalid because:
     networks.default value Additional properties are not allowed ('name' was unexpected)

This is the portion of the docker-compose file that is failing:

networks:
    default:
        driver: bridge
        name: nssams_bridge

When I run (I am on Ubuntu 20.04)

docker-compose --version

It says the version is 1.25.0, I am not sure if that is a high enough version to support 3.4, is my guess.

But I have tried to update docker-compose many ways and none of them seem to work.

I have tried:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod  x /usr/local/bin/docker-compose

and

sudo apt upgrade docker-compose

as well as

sudo pip install docker-compose

but after all of these, the docker-compose --version command still returns 1.25.0, build unknown

So how do I upgrade the docker-compose version?

CodePudding user response:

The name: option was added in Compose file format 3.5, so your 3.4 is one step too old. I'd use 3.8 or 3.9 unless you have a specific reason to use something older:

version: '3.8' # networks: { name: } requires a minimum of 3.5
networks:
    default:
        driver: bridge
        name: nssams_bridge

For many practical uses you can also just let Compose choose the name of the network, since you'll rarely interact with it directly. Should you need manual docker network commands or to refer to the network from another Compose file, Compose will name the network projectname_default, using the current directory's name as the project name. If that's acceptable for you then you can delete this networks: block entirely.

  • Related