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
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 ~
Related
I am creating a docker service with an environment variable:
docker service create --env TEST=123 myservice
And I verify the environment variable was set with
$ docker service inspect myservice
...
ContainerSpec:
Env: TEST=123
...
But then the environment variable does not show up within the docker container. In particular, the code running inside the docker container prints os.Environ() and in the logs I see only the standard environment variable:
$ docker service logs myservice
[HOSTNAME=48bcddab9204 SHLVL=1 HOME=/root PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/app]
So the environment variable "TEST" is not set. How can I set up a service that defines this environment variable?
The output of docker version is
Client:
Version: 20.10.12
API version: 1.41
Go version: go1.17.5
Git commit: e91ed5707e
Built: Mon Dec 13 22:31:40 2021
OS/Arch: linux/amd64
Context: synology
Experimental: true
Server:
Engine:
Version: 20.10.3
API version: 1.41 (minimum version 1.12)
Go version: go1.15.13
Git commit: a3bc36f
Built: Thu Aug 19 07:11:25 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.4.3
GitCommit: ea3508454ff2268c32720eb4d2fc9816d6f75f88
runc:
Version: v1.0.0-rc93
GitCommit: 31cc25f16f5eba4d0f53e35374532873744f4b31
docker-init:
Version: 0.19.0
GitCommit: ed96d00
Variables should be defined in the environment when you use --env. If that's not happening, we'd need a complete example to reproduce. Here's an example showing that it works:
$ docker service create --name env-test --env TESTVAR=123 busybox tail -f /dev/null
nj9l6z57d9pviztyp9pglmv4r
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
697c1bf221b1 busybox:latest "tail -f /dev/null" 20 seconds ago Up 19 seconds env-test.1.vlrepc8mqqvx7gysh2qsymja8
$ docker exec -it env-test.1.vlrepc8mqqvx7gysh2qsymja8 env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=697c1bf221b1
TERM=xterm
TESTVAR=123
HOME=/root
I use the command docker container update --cpus 1 target_container to update the setting. But in most cases it not working and response "you must provide one or more flags when using this command", but somethings it working
Any one know the reason?
Some log is like,
$ docker container update --cpus 0.5 target_container
you must provide one or more flags when using this command
$ docker container update --cpus 0.5 target_container
you must provide one or more flags when using this command
$ docker container update --cpus 0.5 target_container
target_container
the docker version is
Client:
Version: 18.09.7
API version: 1.39
Go version: go1.10.4
Git commit: 2d0083d
Built: Fri Aug 16 14:19:38 2019
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.09.7
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 2d0083d
Built: Thu Aug 15 15:12:41 2019
OS/Arch: linux/amd64
Experimental: false
The docker update man page includes:
--cpus API 1.29+
A docker version can show you if your API is equal or above the API 29, which was with Docker 17.05.
For testing, try --cpus=1 or --cpus=0.5, considering the argument is supposed to be "number of CPUs"
As usual with commands including an hyphen: don't copy-paste it, copy it manually.
I'm having some trouble trying to get metabase running on docker.
I've installed Docker for Windows 7 following this tutotial.
Here is the docker version:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.05.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10.1
Git commit: f150324
Built: Wed May 9 22:20:42 2018
OS/Arch: linux/amd64
Experimental: false
Now when I try to get the metabase running on docker, using
docker run -d -p 3000:3000 --name metabase metabase/metabase
and using
docker logs -f metabase
I get the message after all the setup:
Metabase Initialization COMPLETE
The problem is when I try to access http://0.0.0.0:3000 I get a ERR_ADDRESS_INVALID. I looked for all the ports that are "LISTENING" using
netstat -aon | find /i "listening"
I don't see the 0.0.0.0:3000 listed there.
Docker ps returns:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a283cf6b8d7 metabase/metabase "/app/run_metabase.sh" 4 hours ago Up 4 hours 0.0.0.0:3000->3000/tcp metabase
I'm not sure if this is a problem with metabase image or with docker itself.
Does anyone have an idea on what this could be?
This 0.0.0.0 is not a valid IP address, but a non-routable meta-address
Your application is reachable on your machines IP address / hostname on port 3000.
If you are unsure, what your hostname is, you can run in powershell;
hostname
And then access it using http://your_hostname:3000
I tried to push my docker image onto Google container registry, but I got an Error during authenticating gcloud service on Ubuntu 16.04:
$ gcloud auth configure-docker
and here is the error message I got:
ERROR: (gcloud.auth.configure-docker) Docker configuration file [/home
/username/.docker/config.json] could not be read as JSON: could not
retrieve Docker client version
My docker version is:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:10:01 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:08:31 2018
OS/Arch: linux/amd64
Experimental: false
I have tried other version on Ubuntu 16.04:
$ apt-cache madison docker-ce
These versions are cached:
18.03.0~ce-0~ubuntu
17.12.1~ce-0~ubuntu
17.12.0~ce-0~ubuntu
17.09.1~ce-0~ubuntu
17.09.0~ce-0~ubuntu
17.06.2~ce-0~ubuntu
17.06.1~ce-0~ubuntu ...
and my config.json is:
{
"auths": {},
"credHelpers": {
"asia.gcr.io": "gcr",
"eu.gcr.io": "gcr",
"gcr.io": "gcr",
"staging-k8s.gcr.io": "gcr",
"us.gcr.io": "gcr"
}
}
I found the answer at https://github.com/GoogleCloudPlatform/docker-credential-gcr/issues/10.
I just follow the solution answered by beatcracker:
Check your docker version is bellow 18.03. This is a restriction of gcloud sdk if you want to use the command "$ gcloud docker -- push ".
Install virtual box to install docker-machine.
Install docker-machine.
Run command: $ docker-machine create default
Run command: $ eval $(docker-machine env default)
Run command: $ docker-credential-gcr configure-docker
Run command: $ gcloud auth configure-docker
then you can push docker image to gcr !
I was dealing with a similar issue in GCP Cloud Shell.
When I inspected the /home/username/.docker folder I found the config.json file to be empty.
After deleting the file and executing $ gcloud auth configure-docker again everything worked as expected.
In my case it simply meant that the docker service was not running; apparently the ~/.docker/config.json file is only created when it is
To remediate this from the terminal: sudo systemctl start docker.service
I'm trying to create a Docker secret as per Docker docs:
$ echo | docker secret create my_secret -
and getting the following:
$ echo 'this is my secret' | docker secret create my-secret -
Error reading content from "-": Incorrect function.
This is running under Docker Toolbox in ConEmu:
$ docker version
Client:
Version: 17.07.0-ce
API version: 1.31
Go version: go1.8.3
Git commit: 8784753
Built: Tue Aug 29 17:41:05 2017
OS/Arch: windows/amd64
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:45:38 2017
OS/Arch: linux/amd64
Experimental: false
The behavior manifests itself only for the STDIN option, the command works fine for a file:
$ docker secret create my_secret ./secret.txt
ulec3yck5jpwywg6o7ptxnun7
$ openssl rand -base64 32 | docker secret create secure-secret -
Error reading content from "-": Incorrect function.
$ echo "mydatabasepassword" | docker secret create db_pass -
Error reading content from "-": Incorrect function.