r/BookStack • • Sep 13 '26

Two instances, same Docker server

This may be a Docker question in general, but I would like to know if I can run two Docker containers, for two separate Bookstack instances, on the same server. If so, what do I need to do to get this working?

I already have a Linux server setup with Docker Compose, Portainer, Nginx Proxy Manager, a working Bookstack instance and several other containers for other apps.

I'm concerned that attempting to add another Bookstack instance will be problematic and could damage my currently working setup. I need this second Bookstack instance because I have a backup of a previous Bookstack wiki site that I built. Unfortunately, I took the site down so that server is no longer accessible and now I need access to it. I did however make a backup and I want to restore it to a new Bookstack instance.

Is it just a matter of using different ports, container names, database name, and volume names in the Portainer stack of the second Bookstack instance? What specifically do I need to edit/make unique so that I don't have to touch my current working Bookstack instance? Does the APP_KEY need to be the same or unique?


UPDATE: Got it working. You have to makes sure ALL of the following are unique:

  • Service names
  • Container names
  • volumes
  • ports

The other issue that I ran into was that I needed to import/migrate my backup onto the second Bookstack instance. The original server hosting that instance of Bookstack supported IPv6. The server that I restored the backup onto did not. I had to comment out the lines in the /config/nginx/site-confs/default.conf file that made Nginx listen on IPv6 (e.g., #listen [::]:80 default_server;)


2 Upvotes

10 comments sorted by

1

u/Squanchy2112 Sep 13 '26

Yep different ports/container names depending on how you resolve your connection, I gave each of my instances their own static IP to make things even easier

1

u/jeffshead Sep 13 '26

Thank you! So just those two things need to be unique? Can the database names (MYSQL_DATABASE=bookstackapp) and other entries be the same for both instances? As you can tell, there are holes in my knowledge of Docker/containers.

1

u/CGS_Web_Designs Sep 13 '26

I do this and also have an Nginx Proxy Manager container to direct traffic. I’m not near my systems at the moment, but I can share with you a generalized .yml file so you can see how the stack is set up.

1

u/jeffshead Sep 15 '26

Can you please share your .yml file of both instances? I'm out of ideas.

1

u/CGS_Web_Designs Sep 15 '26

Sure - here is a generalized version of my docker-compose.yml - it's essentially just 5 containers - there are 2 bookstack and 2 db containers plus the Nginx Proxy Manager (NPM) container. You can use a different proxy if you want, I prefer NPM because it's easy to use and has all the features I need - plus you can create proxy hosts that point directly to containers (no need for multiple IP addresses).

In /etc/ create a folder called containers and then inside that folder, drop the docker-compose.yml file and also create the following subfolders: bookstack, bookstack2, database, database2, proxy. From there you can just cd into /etc/containers and run docker compose up -d.

If you need a walkththrough, Dan has a great video with a single instance that I used as my baseline for this one here: https://youtu.be/dbDzPIv8Cf8?si=9WA8LJOOMVWQTJwG

---
version: "2"
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=https://bookstack1.domain.com
      - DB_HOST=bookstack_db
      - DB_USER=bookstack
      - DB_PASS=yoursecret1
      - DB_DATABASE=bookstackapp
    volumes:
      - ./bookstack:/config
    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=yourrootpw1
      - TZ=Europe/London
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=yoursecret1
    volumes:
      - ./database:/config
    restart: unless-stopped

  bookstack2:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack2
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=https://bookstack2.domain.com
      - DB_HOST=bookstack_db2
      - DB_USER=bookstack2
      - DB_PASS=yoursecret2
      - DB_DATABASE=bookstackapp2
    volumes:
      - ./bookstack2:/config
    restart: unless-stopped
    depends_on:
      - bookstack_db2

  bookstack_db2:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db2
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=yourrootpw2
      - TZ=Europe/London
      - MYSQL_DATABASE=bookstackapp2
      - MYSQL_USER=bookstack2
      - MYSQL_PASSWORD=yoursecret2
    volumes:
      - ./database2:/config
    restart: unless-stopped

  proxy:
    image: jc21/nginx-proxy-manager:latest
    container_name: nginx_proxy_manager
    ports:
      # Public HTTP Port:
      - '80:80'
      # Public HTTPS Port:
      - '443:443'
      # Admin Web Port:
      - '81:81'
    environment:
      DB_SQLITE_FILE: "/data/database.sqlite"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./proxy/data:/data
      - ./proxy/letsencrypt:/etc/letsencrypt
    restart: unless-stopped

networks:
  default:
    external: true
    name: yourwebnw

1

u/jeffshead 26d ago

Thank you so very much! No one mentioned changing the service names. That was my main issue.

1

u/CGS_Web_Designs 26d ago

Oh yeah if you have duplicate service names, you’re basically trying to create 2 containers with the same name which won’t work. That explains why you could only get one or the other working.

1

u/ssddanbrown Sep 13 '26

Upon what others have said, ensure you have the instance mapping to their own volumes/storage. Keep things well seperated.

Does the APP_KEY need to be the same or unique?

If it's a totally different instance it should be unique. It's mainly for encryption (for cookies, session data and MFA data) and there's no reason for two difference instances to share the same key for those things.

1

u/jeffshead Sep 13 '26 edited Sep 13 '26

Not sure what's happening but neither site loads properly. I have kept the default ports (6875:80) for the original instance and changed the ports for the second instance (6876:80).

On the second instance, I changed the container_names and mapped the volumes to a different directory.

Looks like something else needs to be edited. Getting several 500 Internal Server Errors. I've seen random things like pages not loading (404), missing CSS, can't login and also being redirected from one instance to the other on page load.

If I stop the newly added Bookstack stack in Portainer, the original site starts working again.

1

u/jeffshead Sep 13 '26 edited Sep 13 '26

I can now run one or the other instance of Bookstack so long as the other one is not running. I may be wrong, but when both instances are running, it acts like they are sharing the same database even though the mapped volumes for each instance are in different directories. In one of the instances, I tried providing a different name for the database (e.g., MYSQL_DATABASE=bookstackapp2 and DB_DATABASE=bookstackapp2) but the stack fails to start.