It looks like a container with the name qgis-desktop-2-4
already exists in the system. You can check the output of the below command to confirm if it indeed exists:
$ docker ps -a
The last column in the above command's output is for names.
If the container exists, remove it using:
$ docker rm qgis-desktop-2-4
Or forcefully using,
$ docker rm -f qgis-desktop-2-4
And then try creating a new container.
Instead of command: docker run
You should use:
docker start **CONTAINER ID**
because the container is already exist
More info
I got this error quite a lot, so now I do a batch removal of all unused containers at once:
docker container prune
add -f
to force removal without prompt.
To list all unused containers (without removal):
docker container ls -a --filter status=exited --filter status=created
See here more examples how to prune other objects (networks, volumes, etc.).
For people landing here from google like me and just want to build containers using multiple docker-compose files with one shared service:
Sometimes you have different projects that would share e.g. a database docker container. Only the first run should start the DB-Docker, the second should be detect that the DB is already running and skip this. To achieve such a behaviour we need the Dockers to lay in the same network and in the same project. Also the docker container name needs to be the same.
1st: Set the same network and container name in docker-compose
docker-compose in project 1:
version: '3'
services:
service1:
depends_on:
- postgres
# ...
networks:
- dockernet
postgres:
container_name: project_postgres
image: postgres:10-alpine
restart: always
# ...
networks:
- dockernet
networks:
dockernet:
docker-compose in project 2:
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: Set the same project using -p
param or put both files in the same directory.
docker-compose -p {projectname} up
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With