We can make “Detail description.” a multi-line description as in the
following example: we check in D:\learn-git>some_js_funcs.js, we
have to issue 3 (three) commands:
⓵ First command, add the file to be checked in (i.e. committed):
D:\learn-git>git add some_js_funcs.js
⓶ Second command, commit with a multi-line description:
It should be apparent that we prepare this command in a text editor, and just
copy and paste this command to the command line console. Note that:
Each message is enclosed within a pair of
double quotes, i.e. "function runAjax( method, ..., errorCallback )."^.
There is a caret ^ character
at the end of each line, except the last line.
THERE MUST BE NOTHING ELSE AFTER THE caret
^ character. A single space did cause a problem for me.
""^ inserts a blank line into the Git commit description.
There is a blank line follows each text line, again except the last line.
⓷ Third and last command, push to the remote repo:
D:\learn-git>git push -u origin main
The second command will pause twice for our input. The first phase, we
just click on the Paste anyway button, the second phase, we
just hit the Enter key — please see illustrations:
The multi-line description as seen in the repo UI:
I took me a few tries to get this working on Windows 10: I document
so if I forget, I can look it up later… This would not work on a
Linux environment, or at least I have not tested yet. Thank you for
reading, I hope you find this useful. Stay safe as always.
Discussing a basic set up process to use the PostgreSQL Official Docker image on Windows 10 Pro, and Ubuntu 22.10 kinetic running on an older HP laptop. Then backup a PostgreSQL database on Windows 10 Pro machine, and restore this backup database to the newly set up Docker PostgreSQL Server 15.1 on the Ubuntu 22.10 machine.
This is the full documentation for these images.
Please note, this page has links to Docker official documents on volumes,
etc., which are necessary to run images such as this.
This post also makes use of PostgreSQL Server password file, whose official
documentation is
34.16. The Password File.
The objectives of this post are rather basic. ❶, getting the Docker
container to store the data in a specific location on the host, of my
own choosing. ❷, implementing the password file on the host and pass
it to the Docker container as per official documentation above.
Of course, the final goal is to connect to a PostgreSQL server
running in a Docker container with whatever clients we need.
PostreSQL Server Docker official image — version 15.1 (Debian 15.1-1.pgdg110+1).
Windows 10 Pro — version 10.0.19045 Build 19045.
Ubuntu — version 22.10 kinetic. The machine it runs
on is an older HP Pavilion laptop. The name of this machine is
HP-Pavilion-15, the rest of this post will use this
name and Ubuntu 22.10 interchangeably.
Windows 10 pgAdmin 4 — version 6.18. Older
versions might not work: when trying to connect, they fail with different
errors.
On Windows 10, “docker” CLI ( Docker Engine ) — version 20.10.17.
On Ubuntu 22.10, “docker” CLI ( Docker Engine ) — version 20.10.22.
Since I already have PostgreSQL Server 14 installed on Windows 10 Pro,
I have to turn its service process off, before setting up another server
in Docker container.
❶ I select to store PostgreSQL data in D:\docker_data\postgresql\.
After creating this directory path, on the docker run command,
it can be mounted as:
My trial and error runs show that the host directory,
which is D:\docker_data\postgresql\ translated to
//d/docker_data/postgresql in this case, must be
COMPLETELY empty, otherwise Docker raises an error.
The image has already been loaded when first pulled. The run command is:
Please note that,I have to do two ( 2 ) commands to
get the password file to work. I did try to run only the final command on
the empty //d/docker_data/postgresql, it did not work.
Please try for yourself.
The obvious question is, can we store the password file in a directory
other than the mounted host data directory D:\docker_data\postgresql\?
I don’t know if it is possible, if it is possible, then I don’t know how
to do it yet.
To connect pgAdmin 4 to the just set up
Docker PostgresSQL Server 15.1, register a new server as:
Host name/address: localhost
Port: 5432.
Username: postgres — I am using the default as per official document.
Password: pcb.2176310315865259
Please note, the Windows 10 version of pgAdmin 4 is 6.18.
Older versions might not work: when trying to connect, they fail with different
errors.
Docker PostgresSQL Server 15.1 is now ready in Windows 10.
On Ubuntu 22.10, I did not do any of the trial and error runs
as Windows 10. I assume that, what do not work on Windows 10,
will also not work on Ubuntu 22.10.
❶ Copy the image to /home/behai/Public/docker-images/,
then load the image with:
❷ I want to store data under /home/behai/Public/database/postgresql/,
create the directories database/postgresql/ under /home/behai/Public/,
and run the first command:
❺ Updated on 16/01/2023 — open port 5432 for external access:
$ sudo ufw allow from any to any port 5432 proto tcp
Since this is a development environment, there is no IP address restriction
applied, in a production environment, I imagine only certain IP addresses are
allowed. Please be mindful of this.
16/01/2023 update ends.
From Windows 10, to connect pgAdmin 4
to Docker PostgresSQL Server 15.1 running on HP-Pavilion-15, register a new server:
Host name/address: HP-Pavilion-15 — it’s better to use
the machine name, since IP addresses can change.
Port: 5432.
Username: postgres — I am using the default as per official document.
Password: pcb.2176310315865259
Please note, the Windows 10 version of pgAdmin 4 is 6.18.
Older versions might not work: when trying to connect, they fail with different
errors.
I already have PostgreSQL Server 14 installed on Windows 10 Pro.
I back up a development database ompdev from this server,
and restore the backup data to Docker PostgreSQL Server 15.1 running
on Ubuntu 22.10: machine name HP-Pavilion-15.
Please note, the above command will not have the create database statement in
the dump file, on the target server, we need to manually create a database to
restore to.
Restoring to HP-Pavilion-15 involves two simple steps.
⓵ Connect pgAdmin 4 to Docker PostgreSQL Server on HP-Pavilion-15,
as discussed. Then create a new
database with:
CREATE DATABASE ompdev;
Please note, it does not have to be pgAdmin 4, we can use
any other client tools available.
If everything goes well, we should now have the database restored and ready for connection
on Docker PostgreSQL Server 15.1 running on Ubuntu 22.10. The below screen capture showing
the ompdev database restored on HP-Pavilion-15:
Docker Compose: how to wait for the MySQL server container to be ready? —
Waiting for a database server to be ready before starting our own application, such as a middle-tier server, is a familiar issue. Docker Compose is no exception. Our own application container must also wait for their own database server container ready to accept requests before sending requests over. I’ve tried two ( 2 ) “wait for” tools which are officially recommended by Docker. I’m discussing my attempts in this post, and describing some of the pending issues I still have.
Synology DS218: unsupported Docker installation and usage… —
Synology does not have Docker support for AArch64 NAS models. DS218 is an AArch64 NAS model. In this post, we’re looking at how to install Docker for unsupported Synology DS218, and we’re also conducting tests to prove that the installation works.
Python: Docker image build — install required packages via requirements.txt vs editable install. —
Install via requirements.txt means using this image build step command “RUN pip3 install -r requirements.txt”. Editable install means using the “RUN pip3 install -e .” command. I’ve experienced that install via requirements.txt resulted in images that do not run, whereas using editable install resulted in images that do work as expected. I’m presenting my findings in this post.
Python: Docker image build — “the Werkzeug” problem 🤖! —
I’ve experienced Docker image build installed a different version of the Werkzeug dependency package than the development editable install process. And this caused the Python project in the Docker image failed to run. Development editable install means running the “pip3 install -e .” command within an active virtual environment. I’m describing the problem and how to address it in this post.
Python: Docker volumes — where is my SQLite database file? —
The Python application in a Docker image writes some data to a SQLite database. Stop the container, and re-run again, the data are no longer there! A volume must be specified when running an image to persist the data. But where is the SQLite database file, in both Windows 10 and Linux? We’re discussing volumes and where volumes are on disks for both operating systems.
Docker on Windows 10: mysql:8.0.30-debian log files —
Running the Docker Official Image mysql:8.0.30-debian on my Windows 10 Pro host machine, I want to log all queries, slow queries and errors to files on the host machine. In this article, we’re discussing how to go about achieving this.
pgloader Docker: migrating from Docker & localhost MySQL to localhost PostgreSQL. —
Using the latest dimitri/pgloader Docker image build, I’ve migrated a Docker MySQL server 8.0.30 database, and a locally installed MySQL server 5.5 database to a locally installed PostgreSQL server 14.3 databases. I am discussing how I did it in this post.
Running the Docker Official Image mysql:8.0.30-debian on my Windows 10 Pro host machine, I want to log all queries, slow queries and errors to files on the host machine. In this article, we’re discussing how to go about achieving this.
Please also notice the following option
in the above
docker run command:
–mount source=mysqlvol,target=/var/lib/mysql.
We shall come back to this option later on.
Using a client tool such as
MySQL Workbench to verify that the new settings are effective:
show variables like 'general_log';
show variables like 'slow_query_log';
show variables like 'log_queries_not_using_indexes';
The above commands should each return
ON. Similarly, the below should each return the corresponding values
we set in the config file:
show variables like 'general_log_file';
show variables like 'slow_query_log_file';
show variables like 'log_error';
➡️ But where
/var/lib/mysql/general_log.log,
/var/lib/mysql/slow_query.log
and
/var/lib/mysql/error.err
are?
In
Python: Docker volumes — where is my SQLite database file?,
I’ve discussed where
Docker volumes or
data files are on
Windows 10 Pro host machine: essentially, due to the installation
of my
Docker Desktop uses
Windows Subsystem for Linux ( WSL 2 ) based engine, I can copy
and paste this directory:
Recall the
docker run option previously mentioned
–mount source=mysqlvol,target=/var/lib/mysql?
source=mysqlvol is the host machine volume
or where the container’s data files live.
Logging all queries can slow down the server, and the log file can get
very big, it should only be used during development, certainly not in
production. Also, these options can be set and reset on the
flight without needing to use the config file or server restart. For
example, via
MySQL Workbench:
SET GLOBAL general_log = 'OFF';
SET GLOBAL general_log = 'ON';
I’ve tried, and it works: I can turn off
general_log, then delete the log file, turn on
general_log again, and a new log file is created.
I do hope you find this helpful and useful. Thank you for reading and stay safe as always.
Steps required to run the official mysql:8.0.30-debian image on Windows 10 with custom config file E:\mysql-config\mysql-docker.cnf.
I want to use my custom config file
E:\mysql-config\mysql-docker.cnf,
when running the Docker Official Image
mysql:8.0.30-debian, on my
Windows 10 Pro machine. I’m describing the
steps to get this working.
❶
mysql-docker.cnf is the only file in
E:\mysql-config\. Its content:
❷ For this
mysql:8.0.30-debian image, the custom config file is
/etc/mysql/conf.d/mysql.cnf.
Its permissions are: owner has read and write;
groups and others has only read. Our own custom
config file must have the same permissions.
❸ Mount
E:\mysql-config\mysql-docker.cnf to change its permissions,
we only need the directory.
E:\mysql-config\ gets translated to
//e/mysql-config. The mounting option is thus:
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | mysql_native_password |
+-------------------------------+-----------------------+
1 row in set (0.01 sec)
⓶ Verify
log_bin_trust_function_creators=1. Please note,
1 is reported as
ON:
mysql> show variables like 'log_bin_trust_%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
❻ Using a
Windows MySQL client tool, we should also be able
to connect to
MySQL in the
mysql-docker container. E.g.:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql" --protocol=TCP --host=localhost --port=3306 --user=root --password=pcb.2176310315865259
Since the value of
default_authentication_plugin is
mysql_native_password we should login successfully.
I.e. we should not get the error:
ERROR 2059 (HY000): Authentication plugin ‘caching_sha2_password’ cannot be loaded: The specified module could not be found.
.
✿✿✿
It took me a while to work this one out… I document it so that it could possibly be of
some helps for others. I am actually using
mysql:8.0.30-debian as my development server. I’ll do
more documents on it later on.
I hope you find this helpful and thank you for reading.