You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name

Docker compose command is failing with conflict

I am bringing up my project dependencies using docker-compose. So far this used to work

However today I tried running the project again after couple of weeks and I was greeted with error message

My docker-compose.yml file is

Docker version is

Docker compose version is

Intended behavior of this call is to:

6 Answers 6

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

Docker Compose normally assigns a container name based on its current project name and the name of the services: block. Specifying container_name: explicitly overrides this; but, it means you can’t launch multiple copies of the same Compose file with different project names (from different directories) because the container name you’ve explicitly chosen won’t be used.

You almost never care what the container name is explicitly. It only really matters if you’re trying to use plain docker commands to manipulate Compose-managed containers; it has no impact on inter-service communication. Just delete the container_name: line.

(For similar reasons you can almost always delete hostname: and links: sections if you have them with no practical impact on your overall system.)

docker restart container failed: «already in use», but there’s no more docker image

I first got my nginx docker image:

Then I started it:

Then I stopped it:

Then I tried to restart it:

Well, it’s an error. But in fact there’s nothing in container list now:

Why I restart nginx image failed? How to fix it?

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

3 Answers 3

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

You find it stopped

You can simply start it using below command:

EDIT: Alternatives If you want to start the container with below command each time,

then use one of the following:

method 2: remove it explicitly after stopping the container before starting the command that you are currently using.

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

As the error says.

You have to remove (or rename) that container to be able to reuse that name

This leaves you two options.

You may delete the container that is using the name «webserver» using the command

docker rm 036a0bcd196c5b23431dcd9876cac62082063bf62a492145dd8a55141f4dfd74

It’s better to remove the unwanted docker and reuse the name.

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

While the great answers are correct, they didn’t actually solve the problem I was facing.

How To:

Safely automate starting of named docker container regardless of its prior state

The solution is to wrap the docker run command with an additional check and either do a run or a stop + run (effectively restart with the new image) based on the result.

This achieves both of my goals:

Running the docker registry with below command always throws an error:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

21 Answers 21

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

I got confused by this also. There are two commands relevant here:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

That means you have already started a container in the past with the parameter

You need to delete that first before you can re-create a container with the same name with

When that container is sill running you need to stop it first before you can delete it with

Or simply choose a different name for the new container.

To get a list of existing containers and their names simply invoke

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

Here what i did, it works fine.

step 1:(it lists docker container with its name)

step 2:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

When you are building a new image you often want to run a new container each time and with the same name. I found the easiest way was to start the container with the —rm option:

Sadly it’s used almost randomly in the examples from the docs

Edit: Read Lepe’s comment below.

You have 2 options to fix this.

You are getting this error because that container name ( i.e registry-v1 ) was used by another container in the past. even though that container may have exited i.e (currently not in use).

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

Cause

A container with the same name is still existing.

Solution

To reuse the same container name, delete the existing container by:

Explanation

Containers can exist in following states, during which the container name can’t be used for another container:

You can see containers in running state by using :

To show containers in all states and find out if a container name is taken, use:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

Here is how I solved this on ubuntu 18:

For each container do:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

The Problem: you trying to create new container while in background container with same name is running and this situation causes conflicts.

The error would be like:

Cannot create continer for service X :Conflict. The name X is already in use by container abc123xyz. You have to remove ot delete (or rename) that container to be able to reuse that name.

Solution rename the service name in docker-compose.yml or delete the running container and rebuild it again (this solution related to Unix/Linux/macOS systems):

or

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

removing all the exited containers

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

I have solved the issue by doing following steps and I hope it helps.

I had problem using NIFI and I have removed and reinstalled using docker. Good luck.

I was running into this issue that when I run docker rm (which usually works) I would get:

The easiest solution to this is removing all stopped containers by running:

I’m just learning docker and this got me as well. I stopped the container with that name already and therefore I thought I could run a new container with that name.

Not the case. Just because the container is stopped, doesn’t mean it can’t be started again, and it keeps all the same parameters that it was created with (including the name).

No problem, since I don’t want those any more I just did docker rm containername at which point my new container was allowed to run with the old name.

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

For example to run Postgres w/o destroying previous state, try this:

You have to remove or rename that container to be able to reuse that name. Смотреть фото You have to remove or rename that container to be able to reuse that name. Смотреть картинку You have to remove or rename that container to be able to reuse that name. Картинка про You have to remove or rename that container to be able to reuse that name. Фото You have to remove or rename that container to be able to reuse that name

Ok, so I didn’t understand either, then I left my pc, went to do other things, and upon my return, it clicked 😀

You download a docker image file. docker pull *image-name* will just pull the image from docker hub without running it.

Now, you use docker run, and give it a name (e.g. newWebServer).

OK. So now, docker run just created a container from your image. If it isn’t running, you can now start it with it’s name:

You can check all your containers (they may or may not be running) with

You can stop and start them (or pause them) with their name or the container id (or just the first few characters of it) from the CONTAINER ID column e.g:

And list all your images, with

In a nutshell, download an image; docker run creates a container from it; start it with docker start (name or container id); stop it with docker stop (name or container id).

Watchtower conflict #37

Comments

davidsarkany commented Mar 23, 2018

The installer does not check whether or not there is an already running container under the name watchtower which caused the following issue:

The text was updated successfully, but these errors were encountered:

davidsarkany commented Mar 24, 2018

I know, but its not user friendly.

bestserver868 commented Mar 24, 2018

what i did was «docker stop watchtower»
then
«docker rm watchtower»

davidsarkany commented Mar 24, 2018

I know how to delete and rename my own watchtower container.
My issue is with it is why is it necessary?
Why does it not check first if there is a name confliction?
Why does it install a new watchtower if I already have one set up for my own liking? (for example it sends emails about updates)?
Having a properly documented shadowbox image (that I can configure to my liking) would be far superior instead of the install_server.sh

trevj commented Mar 26, 2018

@davidsarkany Thanks for the report. We’ll take your suggestion into consideration.

trevj commented Jul 27, 2018

I believe this has been addressed some time ago; the installer now asks whether you want to keep or replace the watchtower container.

Footer

© 2022 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Docker conflict, «already in use by container»

Overview

When a runner is running the same job multiple times, sometimes end up having issues with containers names which result in issues like below:

Sometimes even for the service as reported in #4327 (comment 178140765) as well

This seems to be the case for both Runners that have concurrent set to 1 to 4.

Things we need to investigate

Proposal

First Iteration

Rename containers

All services, build & predefined containers should change their naming structure, to include the CI_JOB_ID so for example:

Notice that we did not rename the volume containers on purpose so that we have a persistent volume between runs.

Remove helper images on context cancellation

Investigate if we call removeContainer on the helper image when the build is canceled/termianted, meaning that the context is cancelled.

Future Iterations

When terminating containers we are sometimes just calling removeContainer & killContainer but we don’t allow for graceful shutdown, that is why first we should Call ContainerStop instead of killContaienr and also call containerStop before we remove the container. If we still fail to remove/kill the container we will simply ignore and log it as an error on the Runner logs.

Since I upgrade to the latest Gitlab CE, my pipelines are failing with those kinds of errors :

It happens when I push to a branch with an already running pipeline. To resolve that, I have to cancel my already running build and relaunch my latest commit pipeline that failed.

I am using Gitlab CE 9.4.3 and Gitlab-multi-runner 9.4.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *