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 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: contact: 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?
31 Answer
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.
2