I cloned original repo docker bookstack
I copied the original Docker-compose. Even I did not want to update to 3,hoping that the things will work.
version: "2"
services:
bookstack:
image: lscr.io/linuxserver/bookstack
container_name: bookstack
environment:
- PUID=1000
- PGID=1000
- APP_URL=
- DB_HOST=bookstack_db
- DB_USER=bookstack
- DB_PASS=*******
- DB_DATABASE=mystackapp
volumes:
- /path/to/data:/config
ports:
- 6875:80
restart: unless-stopped
depends_on:
- bookstack_db
bookstack_db:
image: lscr.io/linuxserver/mariadb
container_name: bookstack_db
environment:
- PUID=1000
- PGID=1000
- MYSQL_ROOT_PASSWORD=******
- TZ=Europe/Budapest
- MYSQL_DATABASE=mystackapp
- MYSQL_USER=bookstack
- MYSQL_PASSWORD=*******
volumes:
- /path/to/data:/config
restart: unless-stopped
But I still get error.
Creating network "docker-bookstack_default" with the default driver
WARNING: Found orphan containers (docker-bookstack_mysql_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating bookstack_db ... done
Creating bookstack ... error
ERROR: for bookstack Cannot create container for service bookstack: Conflict. The container name "/bookstack" is already in use by container "ceede4ebfd4c16842e3a9486fd58b67713be6d527bc3ff2740a251172b2c5967". You have to remove (or rename) that container to be able to reuse that name.
I tried to add the -p flag and specify my project. error again!!
docker-compose -p firstproject up
Creating network "firstproject_default" with the default driver
Creating bookstack_db ... done
Creating bookstack ... error
ERROR: for bookstack Cannot create container for service bookstack: Conflict. The container name "/bookstack" is already in use by container "ceede4ebfd4c16842e3a9486fd58b67713be6d527bc3ff2740a251172b2c5967". You have to remove (or rename) that container to be able to reuse that name.
ERROR: for bookstack Cannot create container for service bookstack: Conflict. The container name "/bookstack" is already in use by container "ceede4ebfd4c16842e3a9486fd58b67713be6d527bc3ff2740a251172b2c5967". You have to remove (or rename) that container to be able to reuse that name.
ERROR: Encountered errors while bringing up the project.
Why? Is this docker-compose file the right one? Do I have circular dependancy in this case?
CodePudding user response:
The error message indicates the problem and how it can be resolved:
ERROR: for bookstack Cannot create container for service bookstack:
Conflict. The container name "/bookstack" is already in use by container "ceede4ebfd4c16842e3a9486fd58b67713be6d527bc3ff2740a251172b2c5967".
You have to remove (or rename) that container to be able to reuse that name.
The problem is that you hard code the container name, so using another project name won't change anything, the container name remains static.
services:
bookstack:
container_name: bookstack
You need to remove the container, i.e. with docker compose down
or docker rm bookstack
.
I would suggest not hard coding the container name to avoid this and other problems. There is little benefit in doing this.
Simply remove it from your yaml file.
services:
bookstack:
image: lscr.io/linuxserver/bookstack
# other stuff without container name
Then you also need to ensure that any other service that used this name to communicate uses the correct name. Since your compose service name is the same as the old static container name, this will work without further changes.
I would also remove any other container_name
key from the yaml file. i.e. bookstack_db
.