3

I am trying to run jenkins swarm agent using the docker-compose provided here.

Issue is I am using a service account provided by my admin team to authenticate against jenkins master and the password for the service account contains special characters \ (backslash) and / (forward slash). Example:

abcdefghifjd12\ab/

The docker secret I created using this password doesn't work. I tried with my personal account which doesn't have any special characters and this works as expected. So I believe issue is with how docker is interpreting these special characters when creating secrets. I tried escaping the back slash and using single quotes for the password but doesn't work. I tried below

#use password as it is in double quotes
echo "abcdefghifjd12\ab/" | docker secret create jenkins-user -

#use backslash to escape backslash
echo "abcdefghifjd12\\ab/" | docker secret create jenkins-user -

#use single quotes
echo 'abcdefghifjd12\ab/' | docker secret create jenkins-user -

None worked. How do I resolve this issue?

Server:

Version: 17.06.2-ee-6

API version: 1.30 (minimum version 1.12)

Go version: go1.8.3

Git commit: e75fdb8

Built: Mon Nov 27 22:44:25 2017

OS/Arch: linux/amd64

Experimental: false

Community
  • 1
  • 1
cnu
  • 477
  • 8
  • 22
  • Base64 your password anywhere, then: echo [your base64] | base64 —decode | docker secret create jenkins-user - – Mike Doe Oct 15 '18 at 04:38

1 Answers1

0

With docker upgraded version I was able to do the same thing.

On SWARM I create a secret on manager-1:

    [manager1] (local) root@192.168.0.41 ~
    $ echo "abcdefghifjd12\ab/" | docker secret create jenkins-user -
    jxykdlqklpo5ml81c4bfa9a4o


    [manager1] (local) root@192.168.0.41 ~
    $ docker service create --secret jenkins-user alpine sleep 1d
    sgmrof1cwwubmhz1qqibu4aof
    overall progress: 1 out of 1 tasks
    1/1: running
    verify: Service converged
    [manager1] (local) root@192.168.0.41 ~
    $ docker service ls
    ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
    sgmrof1cwwub        wizardly_boyd       replicated          1/1                 alpine:latest
    [manager1] (local) root@192.168.0.41 ~


    [manager2] (local) root@192.168.0.43 ~
    docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    f4552c4718c5        alpine:latest       "sleep 1d"          2 minutes ago       Up 2 minutes                wizardly_boyd.1.4gb4nwgiqagfyn10vuvt9pb4v
    [manager2] (local) root@192.168.0.43 ~
    $ docker exec -it f45 sh
    / # cd /run
    /run # cd secrets/
    /run/secrets # ls
    jenkins-user
    /run/secrets # cat jenkins-user
    abcdefghifjd12\ab/

Docker Version information:

    $ docker version
    Client:
     Version:      18.03.1-ce
     API version:  1.37
     Go version:   go1.9.2
     Git commit:   9ee9f40
     Built:        Thu Apr 26 07:12:25 2018
     OS/Arch:      linux/amd64
     Experimental: false
     Orchestrator: swarm

    Server:
     Engine:
      Version:      18.03.1-ce
      API version:  1.37 (minimum version 1.12)
      Go version:   go1.9.5
      Git commit:   9ee9f40
      Built:        Thu Apr 26 07:23:03 2018
      OS/Arch:      linux/amd64
      Experimental: true
    [manager1] (local) root@192.168.0.41 ~
fly2matrix
  • 2,351
  • 12
  • 13
  • your demo steps work in my version of docker as well. so I don't believe this is an issue with docker version. This could be docker-compose or the jenkins-agent issue. For now I am using jenkins token which resolves my issue – cnu Oct 15 '18 at 04:33
  • Is this an answer? If not please update your answer and remove this post. – Mike Doe Oct 15 '18 at 04:36