Score:1

Credential spec not respected by Docker Swarm?

ru flag

I've got a Docker swarm hosted on Windows Server 2022. I've created a credentialspec file since I need the service to use a gMSA. I've also defined a compose file to launch my service:

version: '3.8'

services:
  agent:
    image: privaterepo.local/devops-agent-win-generic:latest
    hostname: '${AZPOOL}_Generic-{{.Task.Slot}}'
    user: "NT AUTHORITY\\NETWORK SERVICE"
    security_opt: 
      - "credentialspec=file://domain_devopsagent.json"
    environment:
      AZP_URL: ${AZURL}
      AZP_POOL: ${AZPOOL}
      AZP_TOKEN: ${AZTOKEN}
      AZP_ONCE: ${AZONCE:-false}
      AZP_REMOVE: ${AZREMOVE:-true}
    deploy:
      replicas: 2
      placement:
        constraints: [node.platform.os == windows]

This starts the containers fine (no errors), and the containers seem to operate as NETWORK SERVICE, as expected, however they do not have access to the network shares as expected.

If I run the container manually then the container DOES have access to the network shares.

docker run --rm -it --user "NT AUTHORITY\NETWORK SERVICE" --security-opt "credentialspec=file://domain_devopsagent.json" privaterepo/devops-agent-win-generic:latest

This leads me to believe there's an issue in either the compose definition or in how the Docker Swarm handles the compose definition.

I've also tried using the credentialspec=raw://<json> version - the container launched fine but as before it couldn't access the network shares.

Any idea what's wrong?

Score:1
ru flag

I've clearly missed a critical part of the documentation on the compose file structures (specifically this part).

The final definition should look like:

version: '3.8'

services:
  agent:
    image: privaterepo.local/devops-agent-win-generic:latest
    hostname: '${AZPOOL}_Generic-{{.Task.Slot}}'
    user: "NT AUTHORITY\\NETWORK SERVICE"
    credential_spec:
      config: credspec
    environment:
      AZP_URL: ${AZURL}
      AZP_POOL: ${AZPOOL}
      AZP_TOKEN: ${AZTOKEN}
      AZP_ONCE: ${AZONCE:-false}
      AZP_REMOVE: ${AZREMOVE:-true}
    deploy:
      replicas: 2
      placement:
        constraints: [node.platform.os == windows]
configs:
  credspec:
    external: true

Prior to launching the above the credspec config needs to be created in the swarm via docker config create (should contain the original credspec file JSON).

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.