Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Stack generation have breaking changes from 2021-09-18 to latest #33

Closed
Ousret opened this issue Nov 14, 2022 · 4 comments
Closed

Stack generation have breaking changes from 2021-09-18 to latest #33

Ousret opened this issue Nov 14, 2022 · 4 comments

Comments

@Ousret
Copy link

Ousret commented Nov 14, 2022

The latest push did break some of our deployments.

Initially posted in #32 but does not per se have the same issue.

Before:

FROM tiangolo/docker-with-compose:2021-09-18
WORKDIR /tmp
COPY docker-compose.yml ./
CMD ['docker-compose', '-f', 'docker-compose.yml', 'config']

After:

FROM tiangolo/docker-with-compose:latest
WORKDIR /tmp
COPY docker-compose.yml ./
CMD ['docker-compose', '-f', 'docker-compose.yml', 'config']

Basic file input docker-compose.yml

version: '3.8'
 
services:
  db:
    image: postgres:14-alpine
    environment:
      POSTGRES_USER: api
      POSTGRES_PASSWORD: azerty
      POSTGRES_DB: api
    volumes:
      - app-db:/var/lib/postgresql/data
 
volumes:
  app-db:

Output before:

services:
  db:
    environment:
      POSTGRES_DB: api
      POSTGRES_PASSWORD: azerty
      POSTGRES_USER: api
    image: postgres:14-alpine
    volumes:
    - app-db:/var/lib/postgresql/data:rw
version: '3.8'
volumes:
  app-db: {}

Output now:

name: tmp
services:
  db:
    environment:
      POSTGRES_DB: api
      POSTGRES_PASSWORD: azerty
      POSTGRES_USER: api
    image: postgres:14-alpine
    networks:
      default: null
    volumes:
    - type: volume
      source: app-db
      target: /var/lib/postgresql/data
      volume: {}
networks:
  default:
    name: tmp_default
volumes:
  app-db:
    name: tmp_app-db
  • version: '3.8' is not present on the generated stack.yml (the target host fallback to version: 1 which is problematic. even though it is on our (input) files.
  • volumes descriptions have changed unexpectedly so there are re-created (not found)
  • it seems that this image generates a compose-compliant (v2) schema file while the command docker stack is not ready.

from remote, not actually the docker-with-compose image

docker stack deploy -c docker-stack.yml --with-registry-auth "xxxx"
unsupported Compose file version: 1.0

hint: the docker-stack.yml seems to be generated using compose v2 instead of docker-compose legacy version.

@do-web
Copy link

do-web commented Nov 16, 2022

I have the problem, i am getting now "unsupported Compose file version: 1.0"

With my docker compose file, before the update all works fine.

version: "3.7"

services:
  km:
    image: ${IMAGE}
    environment:
      - WEB_DOCUMENT_ROOT=/var/www/public
    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: on-failure
      labels:
        caddy: ${CADDY_DOMAIN}
        caddy.reverse_proxy: "{{upstreams 80}}"

networks:
  default:
    external:
      name: caddy_caddy

@tiangolo
Copy link
Owner

It seems you have an older Docker version. So, in the latest version of the Docker Compose file format, the version key is not required and is there only for backwards compatibility: https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-top-level-element

But in previous versions of the spec, it was required to add version: 3 or version: 2, and if it was omitted, it was assumed to be version: 1: https://docs.docker.com/compose/compose-file/compose-versioning/#versioning

But in recent versions of the spec, the version key is no longer required again.

So, you should probably update the Docker version you are using. If you can't do that, you can pin the tag of the Docker image using a date tag like tiangolo/docker-with-compose:2021-09-17. Use the latest date tag that works for you: https://hub.docker.com/r/tiangolo/docker-with-compose/tags

@Ousret
Copy link
Author

Ousret commented Nov 26, 2022

I think that there is a misunderstanding here.
We are well aware of Docker/compose changes in the past year or so.

docker compose plugin (v2) is supposed to be invoked with docker compose instead of docker-compose for backward compatibility purposes.

nothing in this project changeset allows us from understanding it.

Latest Changes
👷 Add GitHub Action for Docker Hub description. PR https://github.com/tiangolo/docker-with-compose/pull/41 by [@tiangolo](https://github.com/tiangolo).
⬆️ Upgrade CI OS. PR https://github.com/tiangolo/docker-with-compose/pull/40 by [@tiangolo](https://github.com/tiangolo).
🔧 Add funding config. PR https://github.com/tiangolo/docker-with-compose/pull/39 by [@tiangolo](https://github.com/tiangolo).
👷 Add automatic scheduled CI every monday. PR https://github.com/tiangolo/docker-with-compose/pull/38 by [@tiangolo](https://github.com/tiangolo).
👷 Add automatic scheduled CI every Monday. PR https://github.com/tiangolo/docker-with-compose/pull/37 by [@tiangolo](https://github.com/tiangolo).
📝 Update README, replace bash with shell, as Bash itself is not installed. PR https://github.com/tiangolo/docker-with-compose/pull/36 by [@tiangolo](https://github.com/tiangolo).
👷 Add alls-green GitHub Action. PR https://github.com/tiangolo/docker-with-compose/pull/35 by [@tiangolo](https://github.com/tiangolo).
👷 Do not run double CI for PRs, run on push only on master. PR https://github.com/tiangolo/docker-with-compose/pull/34 by [@tiangolo](https://github.com/tiangolo).
⬆️ Bump tiangolo/issue-manager from 0.3.0 to 0.4.0. PR https://github.com/tiangolo/docker-with-compose/pull/28 by [@dependabot[bot]](https://github.com/apps/dependabot).
........

Then

ousret@ubuntu:~$ docker run tiangolo/docker-with-compose:latest docker-compose --version
Unable to find image 'tiangolo/docker-with-compose:latest' locally
latest: Pulling from tiangolo/docker-with-compose
Digest: sha256:78700d4aa8d33019199033a93957738b9978d906f7f62304ef36ebc547a358fb
Status: Downloaded newer image for tiangolo/docker-with-compose:latest
Docker Compose version v2.12.2

Also...

ousret@ubuntu:~$ docker run docker:latest docker-compose --version
Unable to find image 'docker:latest' locally
latest: Pulling from library/docker
Digest: sha256:4ae1444ef191366429581854edcf0a16f260b7a0ed90f4d5d1d95265356642ae
Status: Downloaded newer image for docker:latest
Docker Compose version v2.12.2

So this image is becoming useless and that does not seem to bother you.

Everything after FROM docker:latest is rendered useless.
Installing docker-compose from pip targets the 1.x version.

Additional reading for why some may need to remain in v1 docker/cli#2527
Also, some companies may take longer to migrate.

Thanks anyway.

@github-actions github-actions bot removed the answered label Nov 26, 2022
@tiangolo
Copy link
Owner

Ah! Thanks for the clarification.

I don't appreciate the bitter accusation, though. I've been doing this for free, for anyone to use it, in my free time. I would appreciate if you could restrain from these types of accusations when interacting with free open source projects, and asking for free support on issues.

I'll investigate this later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants