Technology Encyclopedia Home >How to install and use Docker on Pop!_OS?

How to install and use Docker on Pop!_OS?

To install Docker on Pop!_OS, a derivative of Ubuntu, you can follow these steps:

Step 1: Update Your System

First, ensure your system is up-to-date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

You can install Docker using the official Docker repository:

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

    sudo apt install -y \
        ca-certificates \
        curl \
        gnupg \
        lsb-release
    
  2. Add Docker’s official GPG key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
  3. Set up the stable repository:

    echo \
      "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  4. Install Docker Engine:

    sudo apt update
    sudo apt install docker-ce docker-ce-cli containerd.io
    

Step 3: Verify the Installation

After the installation, verify that Docker is running correctly:

sudo docker run hello-world

Step 4: Using Docker

You can now use Docker to run containers. For example, to run a simple Nginx server:

sudo docker run --name some-nginx -p 8080:80 -d nginx

This command downloads the Nginx image, runs it, and maps port 8080 on your host machine to port 80 in the container.

Additional Tips

  • Managing Docker as a Non-Root User: To avoid prefixing every Docker command with sudo, you can add your user to the Docker group:

    sudo usermod -aG docker $USER
    

    Log out and log back in for the changes to take effect.

  • Using Docker Compose: For managing multi-container applications, consider installing Docker Compose:

    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    

Cloud-Related Recommendation

If you're looking to deploy Docker containers at scale, consider using Tencent Cloud's TKE (Tencent Kubernetes Engine). TKE simplifies the management of Kubernetes clusters, allowing you to easily deploy, manage, and scale containerized applications. It integrates well with Docker and provides a robust platform for modern application development and deployment.

By following these steps, you should be able to install and use Docker effectively on Pop!_OS.