HiveBrain v1.2.0
Get Started
← Back to all entries
debugbashdockerMinor

docker: Error response from daemon: Conflict. The container name "/basexhttp" is already in use by container

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
basexhttperrorthecontainerdockerresponsealreadynameconflictfrom

Problem

Am I even correctly following the documentation on creating and running a docker container below?

[root@ ~]# 
[root@ ~]# docker run -d \
>     --name basexhttp \
>     --publish 1984:1984 \
>     --publish 8984:8984 \
>     --volume "$HOME/basex/data":/srv/basex/data \
>     --volume "$HOME/basex/repo":/srv/basex/repo \
>     --volume "$HOME/basex/webapp":/srv/basex/webapp \
>     basex/basexhttp:latest
4b827c082bebe45b8be5b7c956f1ada92407181aeec82dc5f71a63f2c5af537e
[root@ ~]# 
[root@ ~]# docker run -ti \
>     --name basexhttp \
>     --publish 1984:1984 \
>     --publish 8984:8984 \
>     --volume "$(pwd)/basex/data":/srv/basex/data \
>     basex/basexhttp:latest
docker: Error response from daemon: Conflict. The container name "/basexhttp" is already in use by container "4b827c082bebe45b8be5b7c956f1ada92407181aeec82dc5f71a63f2c5af537e". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
[root@ ~]# 
[root@ ~]# 
[root@ ~]# docker container list
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@ ~]# 
[root@ ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@ ~]# 
[root@ ~]# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS                          PORTS               NAMES
4b827c082beb        basex/basexhttp:latest   "/usr/local/bin/mvn-…"   About a minute ago   Exited (1) About a minute ago                       basexhttp
[root@ ~]#


referencing:

https://hub.docker.com/r/basex/basexhttp/

https://docs.basex.org/index.php?title=Docker&mobileaction=toggle_view_desktop

where I've copied/pasted what I think are the relevant commands.

Solution

You're attempting to create two different containers, each with the same name. Each time you execute docker run it will create a container, and you've named the containers the same with --name basexhttp. These names must be unique, even among stopped containers. To delete an unneeded container, you can stop and remove it with:

docker container stop basexhttp
docker container rm basexhttp


(Note that docker stop and docker rm also work, but it's easier to read and understand the more verbose syntax)

Code Snippets

docker container stop basexhttp
docker container rm basexhttp

Context

StackExchange DevOps Q#12344, answer score: 5

Revisions (0)

No revisions yet.