I'm following this guide to install docker for my GitLab server running on Ubuntu 16.4.
When I execute the following command:
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
So far so good. However, when I run the next command to register the runner from this guide:
docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register
I keep getting the message:
docker: Error response from daemon: Conflict. The container name "/gitlab-runner" is already in use by container "b055ded012f9d0ed085fe84756604464afbb11871b432a21300064333e34cb1d". You have to remove (or rename) that container to be able to reuse that name.
However, when I run docker container list
to see the list of containers, it's empty.
Anyone know how I can fix this error?
Run
docker ps -a
and you will see all your containers (even the not running ones), if you use the--rm
option on run your container will be removed when stopped if that is the behaviour you are after.You could always just skip the whole
--name
option if you want to create more than one of the same image and don't care about the name.I also came across this, and opened an issue against the GitLab documentation. Here's my comment in there:
Actually, I think the issue might be something different:
On step 3, clicking on the link takes you to https://docs.gitlab.com/runner/register/index.html#docker.
In doing this, you land on the right section, near the end of the page. But this also means that you miss one important bit of information at the top of the page:
That is, the documentation instructions recommend and assume that the gitlab runner container is on another machine. Thus they are not expected to work for containers on the same one.
My suggestion would be to add a note after the register step to check the registration requirements at the top of the page first.
Other than that, @johnharris85's answer would work for registering the runner on the same machine. The only extra thing you'd need to do is to add the
--network="host"
option to the command to do the registration. That is:Just to add my 2-cents as I've also recently been through those GitLab documents to get the Docker GitLab runner working.
Following the Docker image installation and configuration guide, it tells you to start that container, however that I believe, is a mistake, and you want to do that after registering the Runner.
If you did run:
Just remove the docker container with
docker rm -f gitlab-runner
, and move on to registering the runner.This would register the runner, and also place the configuration in
/srv/gitlab-runner/config/config.toml
on the local machine.You can then run the original
docker run
:(NB, if this doesn't work because of the name being in use again - just run the
docker rm -f gitlab-runner
command again - you won't lose the gitlab-runner configuration).And that would stand up the Docker gitlab-runner with the configuration set from the register command.
Hope this helps!
You're trying to run two containers with the same name? Where did these instructions come from? Then in your response you're saying you get the error 'No such container: gitlab-runner-config' but that's not the name of any of the containers you're trying to run?
Seems that your first container is meant to be called
gitlab-runner-config
based on everything else I see in there, including yourvolumes-from
. Probably that's whygitlab-runner
doesn't show up indocker ps
, because you're trying to get volumes from a container that doesn't exist. Try clearing everything, and then run the following:...
EDIT: OK so I read the guide, you're following the instructions wrong. It's saying in step 2, either do the one command, or the two afterwards. Either do a combined config and run container (which is called
gitlab-runner
) or do a config container (calledgitlab-runner-config
) then a runner container (calledgitlab-runner
). You're doing multiple steps with the same container name but mixing them up.