Docker Swarm after Docker Compose V1 deprecation

Compose file specification | Docker Documentation states that

From the end of June 2023 Compose V1 won’t be supported anymore and will be removed from all Docker Desktop versions.

I am still on Docker Swarm and it works well for what we need. But at present or at least the version that’s deployed on AWS Extra Docker repository the docker stack deploy is still not compatible with the Compose Specification. I have to add some extra scripting to modify the resulting file.

Would there be an update to make Docker Swarm support the new Compose Specification?

What are those modifications? Do you mean you can generate a proper compose file but you need to change the script that generates it?

Here’s an example and also added how to set the environment variables such that it will add AWS access keys assuming your compose file also has ${AWS_ACCESS_KEY} as a place holder.

( echo "version: '3.8'"; 
  AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id) \
  AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key) \
  docker compose -f docker-compose.yml convert ) | 
sed "/published:/s/\"//g" | 
egrep -v "^name: " | 
docker stack deploy -c - --with-registry-auth --prune --resolve-image changed api

The first part adds the version element that docker stack deploy requires (at least when I wrote it.

The sed strips off the the quotes around the published port since docker stack deploy requires it to be a number not a string.

The egrep removes the name: value which is not compatible with docker stack deploy

I see. You are right. In fact the documentation of docker stack deploy mentions it too:

The docker stack deploy command uses the legacy Compose file version 3 format, used by Compose V1. The latest format, defined by the Compose specification isn’t compatible with the docker stack deploy command. I have no idea if it will ever be updated to support Compose v2.