Environment Setup - Linux
This guide provides step-by-step instructions on how to install Python 3.10 and Docker on your Ubuntu system using the default package manager and official Docker repositories.
Prerequisites
- Ubuntu operating system
- Administrator access to your Ubuntu system
- An internet connection
Step 1: Update and Upgrade Ubuntu Packages
Before installing new software, it's a good practice to update your Ubuntu package list and upgrade the existing packages to their latest versions.
Open the Terminal.
Update the package list:
shsudo apt updateUpgrade the installed packages:
shsudo apt upgrade -y
Step 2: Install Python 3.10
Ubuntu repositories maintain multiple Python versions, making it easy to install Python 3.10.
Install Python 3.10 by running:
shsudo apt install python3.10Once installed, check the Python version:
shpython3.10 --versionThe output should confirm the installed version of Python,
Python 3.10.x.
Step 3: Install Docker
Installing Docker on Ubuntu requires adding Docker's official repository to ensure you're installing the latest version.
Install prerequisite packages to allow
aptto use a repository over HTTPS:shsudo apt install apt-transport-https ca-certificates curl software-properties-commonAdd Docker’s official GPG key:
shcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -Add the Docker repository to APT sources:
shsudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"Update the package database with the Docker packages from the newly added repo:
shsudo apt updateMake sure you are about to install from the Docker repo instead of the default Ubuntu repo:
shapt-cache policy docker-ceInstall Docker:
shsudo apt install docker-ceVerify that Docker is installed correctly by running the Docker command:
shsudo docker run hello-worldThis command downloads a test image and runs it in a container. If the container runs successfully, it indicates that Docker is installed and working correctly.
Step 4: Manage Docker as a Non-root User
By default, the Docker daemon binds to a Unix socket instead of a TCP port. By default, the Unix socket is owned by the user root, and other users can only access it using sudo. To run Docker commands without sudo, you must add your user to the docker group.
Create the
dockergroup if it doesn't already exist:shsudo groupadd dockerAdd your user to the
dockergroup:shsudo usermod -aG docker $USERLog out and log back in so that your group membership is re-evaluated.
Verify that you can run Docker commands without
sudo:shdocker run hello-world