冲突.容器名称“/gitlab-runner"已被容器使用 [英] Conflict. The container name "/gitlab-runner" is already in use by container

查看:29
本文介绍了冲突.容器名称“/gitlab-runner"已被容器使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照这个 指南为我的 GitLab 服务器安装 docker在 Ubuntu 16.4 上运行.

I'm following this guide to install docker for my GitLab server running on Ubuntu 16.4.

当我执行以下命令时:

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

到目前为止一切顺利.但是,当我运行下一个命令从这个 guide:

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

我不断收到消息:

docker:来自守护进程的错误响应:冲突.容器名称/gitlab-runner"已被容器b055ded012f9d0ed085fe84756604464afbb11871b432a21300064333e34cb1d"使用.您必须删除(或重命名)该容器才能重用该名称.

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.

但是,当我运行 docker container list 来查看容器列表时,它是空的.

However, when I run docker container list to see the list of containers, it's empty.

有人知道我该如何解决这个错误吗?

Anyone know how I can fix this error?

推荐答案

只是为了增加我的 2 美分,因为我最近还通过那些 GitLab 文档来让 Docker GitLab runner 工作.

Just to add my 2-cents as I've also recently been through those GitLab documents to get the Docker GitLab runner working.

遵循Docker 镜像安装和配置 指南,它告诉您启动该容器,但我认为这是一个错误,您希望在注册 Runner 后执行此操作.

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.

如果你确实跑了:

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

只需使用 docker rm -f gitlab-runner 删除 docker 容器,然后转到 注册跑步者.

Just remove the docker container with docker rm -f gitlab-runner, and move on to registering the runner.

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register

这将注册运行器,并将配置放在本地计算机上的 /srv/gitlab-runner/config/config.toml 中.

This would register the runner, and also place the configuration in /srv/gitlab-runner/config/config.toml on the local machine.

然后就可以运行原来的docker run了:

You can then run the original docker run:

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

(注意,如果由于名称再次被使用而这不起作用 - 只需再次运行 docker rm -f gitlab-runner 命令 - 你不会丢失 gitlab-runner配置).

(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).

这将使 Docker gitlab-runner 使用 register 命令中的配置集.

And that would stand up the Docker gitlab-runner with the configuration set from the register command.

希望这会有所帮助!

这篇关于冲突.容器名称“/gitlab-runner"已被容器使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆