How do I get the Ubuntu Dock off the secondary monitor?

Solution 1:

In Ubuntu 20.04 Focal Fossa, there's a simple setting you can configure in Appearance -> Dock -> Show on:

Change Dock settings in Ubuntu 20 Focal Fossa

Solution 2:

CLI method:

You can disable the multiple monitors option for the dock by running the following command in Terminal:

gsettings set org.gnome.shell.extensions.dash-to-dock multi-monitor false

Then you can set your preferred monitor by running

gsettings set org.gnome.shell.extensions.dash-to-dock preferred-monitor <monitor-number>

(Put -1 in place of <monitor-number> for the primary monitor)

GUI method:

See the answer by singrium and the answer by Dan Dascalescu.
(GUI method may not work in special cases)