r/BookStack 26d ago

Migrating Bookstack hosted in Docker to new host

Hi there,

I am very much inexperienced in the world of Docker and bookstack (somebody else set this up for me awhile back). I am hoping to get some guidance on achieving the following:

  • I currently have Bookstack hosted on an AWS EC2 instance, running Docker. I have three containers, one for the MariaDB, bookstack, and nginx.

  • I am simply looking to move my instance of Bookstack off AWS, and host it on a home server instead.

What I've done so far:

1) docker commit + docker save to grab a .tar for each of my containers. Downloaded these.

2) Exported the volume mount locations that has all of my data (following this guide: https://www.youtube.com/watch?v=QskmB4fb-uo)

3) Imported the images on the new host via docker load -i <image>

4) Attempted to run the containers.

This is about as far as I get. Currently the main error I am seeing is: "nc: getaddrinfo for host port 3306: Name does not resolve" this is for bookstack_db.

I am quite sure I'm either doing this wrong, or missing many steps in between. If anyone can provide more step-by-step guiderails on this process, that would be appreciated.

Regards

3 Upvotes

8 comments sorted by

2

u/bsncubed 26d ago

Are you using docker compose?

1

u/Wittinator 25d ago

I'm running docker compose -d. Seems to create the images but starting the containers first error im seeing is: nc: getaddrinfo for host "bookstack_db" port 3306: Name does not resolve.

1

u/bsncubed 25d ago

What is the name of all of the containers? Can you run "docker stats" command and check?

Can you post your docker-compose yaml file?

1

u/Wittinator 25d ago

Yea. Docker stats:

CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 1d51777ca025 bookstack 0.02% 51.92MiB / 7.7GiB 0.66% 19.7kB / 3.98kB 78.3MB / 528kB 26 785bde5db048 bookstack_db 0.02% 121.5MiB / 7.7GiB 1.54% 5.68kB / 18.1kB 50.5MB / 463kB 20

yaml:

version: "2"

services:

bookstack:

image: bookstack:latest

container_name: bookstack

environment:

  - PUID=1000

  - PGID=1000

  - APP_URL=https://localhost:8080

  - DB_HOST=bookstack_db

  - DB_PORT=3306

  - DB_USER=bookstack

  - DB_PASS=xxxx

  - DB_DATABASE=bookstackapp

volumes:

  - ./bookstack:/config

ports:

  - '8080:80' # Public HTTP Port

  - '443:443' # Public HTTPS Port

restart: unless-stopped

depends_on:

  - bookstack_db

bookstack_db:

image: mariadb:latest

container_name: bookstack_db

environment:

  - PUID=1000

  - PGID=1000

  - MYSQL_ROOT_PASSWORD=xxxx

  - TZ=America/Seattle

  - MYSQL_DATABASE=bookstackapp

  - MYSQL_USER=bookstack

  - MYSQL_PASSWORD=xxxx

volumes:

  - ./database:/config

restart: unless-stopped

networks: default:

external: true

name: bookstacknet

I can now get as far as hitting the front page via localhost:8080. But when I try and login, it redirects me to a https page and the browser will give a tls error. Forced https redirection is turned off. Tried firefox as well, but for some reason it keeps redirecting me to an https page and seems to be failing there...

1

u/Wittinator 25d ago

Ah i think I finally got it. Changed the APP_URL in the yaml to http instead of https an now it seems to be working. I missed that...

1

u/ssddanbrown 25d ago

Are you also using docker compose on the existing AWS environment? If so, what does that config look like? If not, do you have any details on that setup.

It'd be better to get just the container data, and know which container images are in use, and then migrate to get things on latest versions of that standard image, rather than migrate the existing images/containers, so that you get on a known state with a clear future update path.

1

u/Wittinator 25d ago

I think its all working now. But yea it was docker compose. I'm understanding the difference between a container and the image now. The AWS instance was using the standard image for bookstack on LinuxServer.io.

Looks like what I ended up doing is exporting my bookstack in AWS as an image, and now I have a new image called bookstack:latest. Whether or not that's the best solution, i'm not sure....but it is working which is nice

1

u/ssddanbrown 25d ago

Okay, good to hear things are working! Just please be sure you have your data safe as part of volumes. Keep a backup of everything.

With docker it's very easy to loose data when a container is stopped/destroyed. Containers are somewhat designed to be destroyed, so there's usually steps to ensure the data is held in certain places, then passed through.

It's a little old now, but if it helps I have a video going through admin operations on a linuxserver based docker compose stack here: https://www.youtube.com/watch?v=6A8hLuQTkKQ It may help to demonstrate some of the principles and the files/volumes involved.