Docker compose config, --env.file, docker pull and docker stack deploy

2k Views Asked by At

I have a problem with these docker commands. I want join the docker compose command to docker stack deploy:

I have written the following instructions in my script:

    docker-compose --env-file $HOME/myinstallation/yml/env config

    docker-compose pull

    docker stack deploy --compose-file $HOME/myinstallation/yml/docker-compose.yml myinstallation

The first command it works and my compose is pardes correctly, but compose pull doesn't woork.

I have thise error:

WARNING: "The service variable is not set. Defaulting to a blank string". And then it pull the latest of my service:

maybe my declaration of tags is not correct?

in my docker compose my service has these tag

    version: "3.6"

    networks:
      mynetwork:
        external: true
        name: mynetwork

    services:

      myservice:
        deploy:
          mode: replicated
          placement:
            constraints:
              - node.role == manager
          replicas: 1
          restart_policy:
            condition: on-failure
        image: myinstallation/test:${service}
        networks:
           -mynetwork
        ports:
           88:80

and in my env file i have setted the variable in this mode:

    service=1.0.2

Any idea? Can someone help me? What am I doing wrong?

Thank you so much

1

There are 1 best solutions below

1
user11566205 On

AFAIK docker-compose --env-file $HOME/myinstallation/yml/env config won't overwrite your targeted compose file.

I would suggest trying to pipe the output of docker-compose --env-file $HOME/myinstallation/yml/env config

into

docker stack deploy ..

This way

docker-compose --env-file $HOME/myinstallation/yml/env config |
docker stack deploy --compose-file - myinstallation