portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
30.33k stars 2.43k forks source link

Portainer Secrets cannot be found by Stack Compose File #11950

Open M0n7y5 opened 2 months ago

M0n7y5 commented 2 months ago

Before you start please confirm the following.

Problem Description

Unable to use secrets defined in Portainer UI in docker compose file when creating or updating Stack. Every time i try to do so i get error message saying undefined secret

Here secrets UI image

Relevant stack file part: image

Expected Behavior

Being able to use my secrets defined in Portainer

Actual Behavior

Every time i try to use already defined secret then i get error message saying undefined secret. image

Steps to Reproduce

Create any secret in Portainer UI and try to using while creating Service Stack

Portainer logs or screenshots

No response

Portainer version

2.19.5

Portainer Edition

Community Edition (CE)

Platform and Version

Docker Swarm 26.1.3

OS and Architecture

Ubuntu jammy 22.04 x86_64

Browser

No response

What command did you use to deploy Portainer?

No response

Additional Information

No response

jamescarppe commented 2 months ago

If you have created a secret outside of the stack file you need to add the secret as external so that Docker knows to use the existing one. This is done through a separate secrets: section in the stack file, the same way you would do volumes. A simple example stack file might look like this:

version: "3"
services:
  nginx:
    image: nginx:latest
    secrets:
      - my_secret

secrets:
  my_secret:
    external: true

You reference the secret (my_secret) in the service as usual, but you also need to add the secrets section. Note if you are creating a secret as part of the stack, you would need to include this section as well (just without the external: true option).

M0n7y5 commented 2 months ago

@jamescarppe i think i tried this first tho i may miss-configured something. I'll try again and see if that helps.