docker machine fails to create instances on AWS when the gitlab runner token contains an underscore
Expected behavior
when I use docker machine with gitlab runner to create AWS instances I need to supply the parameter MachineName, which requires a %s in it. That will be replaced by the runner token.
Relevant logs and/or screenshots
root@ip-10-2-0-109:~# cat /etc/gitlab-runner/config.toml
concurrent = 10
check_interval = 5
[[runners]]
name = "auto-scale-runner-aws"
limit = 15
url = "http://1.2.3.4/"
token = "afz_7WP1Y2-515gXU43m"
executor = "docker+machine"
[runners.docker]
tls_verify = false
image = "docker:latest"
privileged = true
disable_cache = false
volumes = ["/cache"]
services = ["docker:dind"]
shm_size = 0
[runners.cache]
Type = "s3"
ServerAddress = "s3-eu-west-1.amazonaws.com"
BucketName = "gitlab"
[runners.machine]
IdleCount = 2
IdleTime = 2700
MaxBuilds = 100
MachineDriver = "amazonec2"
MachineName = "%s-gitlab"
MachineOptions = [
"amazonec2-region=eu-west-1",
"amazonec2-vpc-id=something",
"engine-storage-driver=overlay",
"amazonec2-ami=ami-6d48500b",
"amazonec2-tags=environment,staging,docker-machine,true,project,gitlab-runner",
"amazonec2-subnet-id=something",
"amazonec2-security-group=security_group_docker_machine",
"amazonec2-request-spot-instance",
"amazonec2-spot-price=0.50"]
OffPeakTimezone = ""
OffPeakIdleCount = 0
OffPeakIdleTime = 0
Jan 16 10:18:37 ip-10-2-0-109 gitlab-runner[16411]: time="2018-01-16T10:18:37Z" level=error msg="Error creating machine: Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -" driver=amazonec2 name="runner-afz_7wp1-1516097917-2eee1465-gitlab" operation=create
Environment description
root@ip-10-2-0-109:~# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.12.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-1041-aws
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.858GiB
Name: ip-10-2-0-109
ID: WVPR:R2HD:XIMP:ZX6O:XCR3:5W7V:YLIN:SJDW:BUS4:BESU:YLAB:M74A
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
ii gitlab-ce 10.3.3-ce.0 amd64 GitLab Community Edition (including NGINX, Postgres, Redis)
ii gitlab-runner 10.3.0 amd64 GitLab Runner
Used GitLab Runner version
root@ip-10-2-0-109:~# gitlab-runner --version
Version: 10.3.0
Git revision: 5cf5e19a
Git branch: 10-3-stable
GO version: go1.8.5
Built: Fri, 22 Dec 2017 08:47:19 +0000
OS/Arch: linux/amd64
Edited by Walter Heck