Coder Perfect

“Conflict… already in use by container,” says the Docker error response from the daemon.

Problem

I’ve been running Quantum GIS on my PC with Docker and the instructions I found here: docker-qgis-desktop is a desktop version of docker-qgis. QGIS desktop is run in a simple docker container.

Everything was OK until last week, when I began to receive the following error message:

Despite examining this site for answers, I’m still not sure what this represents. I hadn’t changed anything and had been successfully launching the container with the following command:

sudo docker run --rm --name="qgis-desktop-2-4"     -i -t     -v ${HOME}:/home/${USER}     -v /tmp/.X11-unix:/tmp/.X11-unix     -e DISPLAY=unix$DISPLAY     kartoza/qgis-desktop:latest

What can I do about it?

Asked by marty_c

Solution #1

It appears that the system already has a container named qgis-desktop-2-4. You may confirm if it exists by looking at the result of the program below:

$ docker ps -a

The last column in the output of the above command is for names.

Remove the container if it exists by using:

$ docker rm qgis-desktop-2-4

Or forcefully using,

$ docker rm -f qgis-desktop-2-4

Then try to make a new container.

Answered by Dharmit

Solution #2

instead of “docker run,” use “docker” instead of “docker”.

You should use:

docker start **CONTAINER ID**

due to the fact that the container already exists

More info

Answered by nasir taha

Solution #3

I’ve been getting this issue a lot lately, so I’ve started doing a batch removal of all unneeded containers at once:

docker container prune 

To compel removal without prompting, add -f to the command.

To create a list of all unused containers (without removing them):

docker container ls -a --filter status=exited --filter status=created 

More examples of how to prune different objects may be found here (networks, volumes, etc.).

Answered by Noam Manos

Solution #4

For those who, like me, came here from Google and only wish to build containers with numerous docker-compose files and a single shared service:

You may have multiple projects that share a container, such as a database docker container. The DB-Docker should only be started on the first run; the second should detect that the DB is already running and bypass it. We need the Dockers to be on the same network and in the same project to achieve this behavior. The name of the docker container must also be the same.

1st, in docker-compose, set the same network and container name.

project 1: docker-compose

version: '3'

services:
    service1:
        depends_on:
            - postgres
        # ...
        networks:
            - dockernet

    postgres:
        container_name: project_postgres
        image: postgres:10-alpine
        restart: always
        # ...
        networks:
            - dockernet

networks:
    dockernet:

project 2: docker-compose

version: '3'

services:
    service2:
        depends_on:
            - postgres
        # ...
        networks:
            - dockernet

    postgres:
        container_name: project_postgres
        image: postgres:10-alpine
        restart: always
        # ...
        networks:
            - dockernet

networks:
    dockernet:

2nd, use the -p argument to set the same project or place both files in the same directory.

-p projectname up docker-compose

Answered by Karl Adler

Solution #5

There are no difficulties with the newest version of kartoza/qgis-desktop.

I ran

docker pull kartoza/qgis-desktop

followed by

docker run -it --rm --name "qgis-desktop-2-4" -v ${HOME}:/home/${USER} -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY kartoza/qgis-desktop:latest

I tried several times without getting the conflict error – you must exit the program first. Please keep in mind that the specifications differ slightly.

Answered by Alex Nolasco

Post is based on https://stackoverflow.com/questions/31676155/docker-error-response-from-daemon-conflict-already-in-use-by-container