Score:0

Docker-compose, installed with Snap, gives error on YML file

in flag

I've installed docker with Snap Package Manager. It says it has the latest version, but docker-compose gives error about the syntax which looks like it's not the latest version.

Example docker-compose.yml

version: '3.9'

services:

  documentation:
    image: nginx:latest
    container_name: docs
    volumes:
      - ./site:/var/www/html
      - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./var/log/nginx:/var/log/nginx
    networks:
      my-net:
        ipv4_address: 172.30.0.110

networks:
  my-net:
    external: true
    name: my-net

On DigitalOcean

$ docker-compose --version
docker-compose version 1.27.4, build 40524192

And the docker-compose config command looks good.

On my Ubuntu with Docker in Snap

cops@emdev01:~/cops/documentation$ docker-compose --version
docker-compose version 1.25.5, build unknown

And the docker-compose config command gives the following output:

$ docker-compose config
ERROR: Version in "./docker-compose.yml" is unsupported. 
You might be seeing this error because you're using the wrong Compose file version. 
Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions 
under the `services` key, or omit the `version` key and place your service definitions at the 
root of the file to use version 1.

For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

The docker-compose used:

$ which docker-compose
/snap/bin/docker-compose

And the info shows the following:

$ sudo snap info docker
name:      docker
summary:   Docker container runtime
publisher: Canonical✓
store-url: https://snapcraft.io/docker
contact:   https://github.com/docker-snap/docker-snap/issues?q=
license:   (Apache-2.0 AND MIT AND GPL-2.0)
description: |

[SNIP]

services:
  docker.dockerd: simple, enabled, active
snap-id:      sLCsFAO8PKM5Z0fAKNszUOX0YASjQfeZ
tracking:     latest/stable
refresh-date: today at 09:46 UTC
channels:
  latest/stable:    20.10.8      2021-08-27 (1125) 122MB -
  latest/candidate: 20.10.8      2021-09-29 (1234) 121MB -
  latest/beta:      20.10.9      2021-10-08 (1310) 122MB -
  latest/edge:      20.10.9      2021-11-09 (1399) 122MB -
  17.03/stable:     17.03.2-ce-1 2017-07-20  (159)  42MB -
  17.03/candidate:  17.03.2-ce-1 2017-06-30  (159)  42MB -
  17.03/beta:       ↑
  17.03/edge:       17.03.2-ce-1 2017-06-30  (159)  42MB -
installed:          20.10.8                 (1125) 122MB -
adminlinux@emdev01:~$

So, the above look like I'm using the latest Docker which is installed with Snap.

Then why do I get the error on the docker-compose file?

muru avatar
us flag
https://docs.docker.com/compose/compose-file/compose-file-v3/ says the latest Compose file version (`3.9`) is implemented by Docker Compose 1.27.0+. The snap has an older version, as you can see. Docker Compose is released independently of Docker itself.
BertC avatar
in flag
Aha, thanks. And since docker-compose is not offered as a Snap-Package, I need to install it the old-fashioned way I guess.
BertC avatar
in flag
Ok, this does not work. /snap/bin/docker-compose is still there and the docker-compose installed on /usr/local/bin is not accessible by a non-priv user.
Score:0
in flag

Fixed it by uninstalling the Snap version of Docker and installing Docker the old-fashioned way with apt.

The reason is that Snap does some weird things. @muru told me that docker-compose is no part of the Snap Package. But there is a /snap/bin/docker-compose. That one is an old version, and there is no Snap Package for Docker-Compose, let alone one of the more recent dates.

Therefore I've removed Docker from Snap and installed Docker again with Apt.

Now everything works as expected.

muru avatar
us flag
I didn't say docker-compose isn't part of the docker snap package. I said docker-compose is released independently of docker, so the latest docker snap doesn't need to have the latest docker-compose.
BertC avatar
in flag
Aha, ok, sorry. Misunderstood then. At least I have it working now without Snap
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.