Running the Charlesreid1 Docker Pod¶
This docker pod runs the main charlesreid1.com site.
To run the pod, use the
The Docker Compose File¶
docker-compose.yml file contains all the directives needed
to run a docker pod of containers that make Charlesreid1.com work.
Why use docker-compose instead of docker? docker-compose is the preferred way to run multiple containers.
Huh? Where's docker-compose.yml??
Instead of a
you'll see a
You need to fix this YML file by hard-coding your
MYSQL password in the file.
(There is also a Jinja template,
usable with charlesreid1-ansible.)
See the steps below for using the "fixme" file.
Running Charlesreid1 Docker Pod from Command Line¶
We start by covering how to run the docker pod from the command line.
First, set the MySQL password using a sed one-liner:
$ sed "s/REPLACEME/YoFooThisIsYourNewPassword/" docker-compose.fixme.yml > docker-compose.yml
Now you can run the container pod with
docker-compose up # interactive docker-compose up -d # detached
or, if you want to rebuild all the containers before running up,
docker-compose up --build
If you just want to rebuild the containers,
and this will rebuild the containers from scratch:
docker-compose build --no-cache
WARNING: for large, complicated container images, this command can take a very long time. Use with care.)
You can restart all containers in a pod using the restart command:
WARNING: this will NOT pick up changes to Dockerfiles or to files that are mounted into the container. This simply restarts the container using the same image (in memory) that was previously running, without getting an up-to-date container image.
Running Charlesreid1 Docker Pod as Startup Service¶
If you want to run the pod as a startup service,
scripts/ folder for a startup service
that can be used with systemd. This is also included
[Unit] Description=charlesreid1 docker pod Requires=docker.service After=docker.service [Service] Restart=always ExecStart=/usr/local/bin/docker-compose -f /home/charles/codes/docker/pod-charlesreid1/docker-compose.yml up ExecStop=/usr/local/bin/docker-compose -f /home/charles/codes/docker/pod-charlesreid1/docker-compose.yml stop [Install] WantedBy=default.target
Now install the service to
and activate it:
sudo systemctl enable pod-charlesreid1.service
Now you can start/stop the service with:
sudo systemctl (start|stop) pod-charlesreid1.service
NOTE: if you need to debug the containers,
or update any config files copied into the container,
be sure and stop the service before doing a
docker-compose stop or a
docker-compose up --build,
otherwise the pod will continually respawn.
Workflow for Charlesreid1 Docker Pod Updates¶
This section covers a workflow if you're updating the docker pod.
As noted above, a simple
docker-compose restart won't pick up
changes in Dockerfiles or files mounted into the image, so
you often need to stop the containers and restart them after
rebuilding the container images.
However, if you update your files (particularly if you add a lot of new apt packages), it can take a long time to build the containers. This can result in a lot of downtime if you take the containers down before rebuilding them.
To minimize downtime, use the following workflow:
docker-compose buildto rebuild the images, leaving the pod running (they are not affected)
docker-compose downto bring the pod down
docker-compose upto bring the pod up
It may take a few seconds to bring the pod down, and that will be your total amount of downtime.
Restoring Docker Pod from Backups¶
Also see Backups.md.
Now that the pod is running, you probably need to seed it with data.
You will need two mediawiki restore files and two gitea restore files, everything else comes from git.charlesreid1.com or github.com (this will create a bootstrapping problem if you have no git.charlesreid1.com):
- MediaWiki database backup
- MediaWiki files (images) backup
- Gitea dump zip file
- Gitea avatars zip file
Now you can restore the database as follows:
- MySQL database restore scripts for MediaWiki are in
- MediaWiki image directory restore scripts are in
- Gitea database and avatars come from backups using scripts in
To restore a database from a dump:
cd utils-mysql/ ./restore_database.sh /path/to/dump/wikidb.sql
The MySQL container must be running for this to work. (You may need to adjust the MySQL container name in the script.)
To restore the MediaWiki images directory:
cd utils-mw/ ./restore_wikifiles.sh /path/to/wikifiles.tar.gz
The gitea container can be restored from a backup as follows:
cd utils-gitea/ ./restore_gitea.sh /path/to/gitea-dump.zip /path/to/gitea-avatars.zip