Johnny Matthews | Install Docker on Ubuntu

Yeah, this isn’t revolutionary and there are 1000% better scripts out there. But I frequrently find myself needing to install Docker on Ubuntu VMs, and since I use this blog repo as my personal knowledge-base, here we are. This was written on 25th of June 2025.

Alright, here we go:

  1. Grab this script:
wget https://johnnymatthews.dev/blog/2025-06-25-install-docker-on-ubuntu/install-docker.sh
  1. Give it executable permissions:
chmod +x install-docker-on-ubuntu.sh
  1. Run it:
./install-docker-on-ubuntu.sh
  1. Enable the new docker group that your user is now in:
newgrp docker

But Johnny, why do I have to run that newgrp thing after the script? Why not just add that into the script itself!

You can run newgrp docker at the end of the script, but shit won’t do what you think it’ll do. When you run newgrp in a script, it starts a new shell with the docker group active, but this new shell is confined to the script’s execution context. Once the script ends, you get kicked out to your original shell session where the group change isn’t active.

Anyway, that’s everything. Be gone.