Docker is a powerful tool for creating, deploying, and running applications using containers. In this guide, we will walk you through the installation of Docker Engine on FunOS, a lightweight Linux distro based on Ubuntu.
Install Docker Engine
1. Uninstall Old Versions of Docker
If you have previously installed Docker or any other container management tools, it’s important to remove them before installing Docker Engine to avoid conflicts. Run the following command to remove older versions:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt remove $pkg; done
This command ensures that any previous Docker-related packages are cleanly uninstalled from your system.
2. Set Up Docker’s Apt Repository
Docker packages are available through Docker’s official repositories. Before installing, you need to configure these repositories.
Step 1: Install Required Dependencies
Update your system and install the ca-certificates
and curl
packages, which are necessary for downloading and setting up the Docker repository.
sudo apt update
sudo apt install ca-certificates curl
Step 2: Add Docker’s Official GPG Key
Next, you need to add Docker’s GPG key to verify the integrity of the packages:
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
Step 3: Add Docker Repository to Apt Sources
Now that the GPG key is in place, add Docker’s apt repository to your system’s sources list:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 4: Update Package Index
Update your package index to include Docker’s repository:
sudo apt update
3. Install Docker Packages
With the repository added and updated, you can now proceed to install Docker Engine and other related packages:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
These packages include:
- docker-ce: The Docker Engine itself.
- docker-ce-cli: Docker command-line interface.
- containerd.io: The container runtime.
- docker-buildx-plugin: The buildx tool for building multi-platform images.
- docker-compose-plugin: For managing multi-container applications.
4. Verify Docker Installation
Once the installation is complete, you can verify that Docker Engine is working correctly by running the hello-world
container:
sudo docker run hello-world
This command pulls and runs a small container that outputs a message confirming that Docker is installed and running properly.
5. Manage Docker as a Non-Root User
By default, Docker requires root privileges to run commands. However, you can configure Docker to be used by a non-root user to avoid needing sudo
every time.
Step 1: Create the Docker Group
Create a new group called docker
:
sudo groupadd docker
Step 2: Add Your User to the Docker Group
Add your user to the docker
group:
sudo usermod -aG docker $USER
Step 3: Log Out and Log Back In
To apply the group changes, log out of your session and log back in. Alternatively, you can activate the changes without logging out by running the following command:
newgrp docker
Step 4: Verify Docker Without Sudo
You can now check if Docker runs without needing sudo
by running the following command:
docker run hello-world
If everything is set up correctly, you should see the same output as in step 4, but without having to prepend sudo
to the command.
Uninstall Docker Engine
If you want to remove Docker Engine and related packages from your system, follow these steps.
1. Uninstall the Docker Engine, CLI, containerd, and Docker Compose packages
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
This will remove Docker but keep your Docker images, containers, and volumes intact.
2. Remove the repository and key (optional)
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo rm -f /etc/apt/keyrings/docker.asc
sudo apt update
This will remove the Docker repository and Docker’s GPG key.
3. Remove Docker Data (optional)
If you want to completely remove all Docker images, containers, volumes, and configuration files, run the following commands:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
Conclusion
Docker Engine is now successfully installed on FunOS, and you’re ready to start building and deploying containerized applications. By following the steps above, you can manage Docker efficiently without root privileges. Happy containerizing!
Leave a Reply