Skip to content

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.

  1. Open the Terminal.

  2. Update the package list:

    sh
    sudo apt update
  3. Upgrade the installed packages:

    sh
    sudo apt upgrade -y

Step 2: Install Python 3.10

Ubuntu repositories maintain multiple Python versions, making it easy to install Python 3.10.

  1. Install Python 3.10 by running:

    sh
    sudo apt install python3.10
  2. Once installed, check the Python version:

    sh
    python3.10 --version

    The 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.

  1. Install prerequisite packages to allow apt to use a repository over HTTPS:

    sh
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
  2. Add Docker’s official GPG key:

    sh
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  3. Add the Docker repository to APT sources:

    sh
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  4. Update the package database with the Docker packages from the newly added repo:

    sh
    sudo apt update
  5. Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:

    sh
    apt-cache policy docker-ce
  6. Install Docker:

    sh
    sudo apt install docker-ce
  7. Verify that Docker is installed correctly by running the Docker command:

    sh
    sudo docker run hello-world

    This 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.

  1. Create the docker group if it doesn't already exist:

    sh
    sudo groupadd docker
  2. Add your user to the docker group:

    sh
    sudo usermod -aG docker $USER
  3. Log out and log back in so that your group membership is re-evaluated.

  4. Verify that you can run Docker commands without sudo:

    sh
    docker run hello-world