Oliver Dimes Blog

A programming blog containing some technical information but lots of ramblings about lots of different things!

Today, I was going about configuring an Ubuntu VM with Docker which is one of my most common things that I end up doing and some additional bits of config.

I was originally thinking of doing something like using Ansible however because of the simple nature of this I decided to not go down that route, it might be something I might explore in the future but for now a simple shell script can do.

There are a couple of things that I always do with an Ubuntu VM/Machine :

  • VSCode, whilst not everyones favourite it’s a swiss army knife and its the one I always use on my personal rigs
  • Docker, I do the majority of my development/testing within Docker containers and just having docker setup is useful
  • Google Chrome, Firefox is installed by default however realistically there will be times where you’ll be like “man I wish I had chrome right now”
  • DNS Server to 1.1.1.1, this is more of a personal preference as I’ve had issues with my default ISP DNS server not playing nice with Microsoft domains specifically. You could also change this to 8.8.8.8 or anything like that
#!/bin/bash
# Install VSCode : <https://code.visualstudio.com/docs/setup/linux>

sudo apt-get install wget gpg -y
wget -qO- <https://packages.microsoft.com/keys/microsoft.asc> | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] <https://packages.microsoft.com/repos/code> stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg

# Install Docker : <https://docs.docker.com/engine/install/ubuntu/>
# Add Docker's official GPG key:
sudo apt-get update -y
sudo apt-get install ca-certificates curl -y
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \\
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <https://download.docker.com/linux/ubuntu> \\
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \\
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sudo docker run hello-world

# Install Google Chrome : <https://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line>
sudo apt-get install libxss1 libappindicator1 libindicator7 -y
wget <https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb>
sudo apt install ./google-chrome*.deb -y

# Changing the DNS address to 1.1.1.1
sudo cp /etc/resolv.conf /etc/resolv.conf.backup
sudo echo "nameserver 1.1.1.1" > /etc/resolv.conf
# Display the new DNS configuration
sudo echo "DNS has been changed to:"
sudo cat /etc/resolv.conf

Ended up using the following guides to make this script take about 5 minutes to write :

My plans for the future is to have multiple scripts for multiple Linux operating systems that I use commonly enough, having docker preinstalled and ready to go is quite important. The code is available on Github : https://github.com/effeect/quickstart-scripts

Many Thanks, Ollie

Posted in

Leave a comment