Introduction to Docker#
Getting Started with Docker on Arch Linux
To use Docker, you need to install and configure it on your system. If you’re not familiar with SSH or setting up your environment, check my previous blog.
Installing Docker#
On Arch Linux, install Docker using pacman:
sudo pacman -S dockerStarting and Enabling Docker Service#
After installation, start the Docker service:
sudo systemctl start dockerTo enable Docker at system startup:
sudo systemctl enable dockerTo verify that Docker is running:
sudo systemctl status dockerCreating a Docker Container#
Pulling an Image from Docker Hub#
Download the Ubuntu image:
sudo docker pull ubuntuCreating a New Container#
To create a new container:
sudo docker create --name my-container ubuntu⚠ Note: If you encounter a timeout error, you may need to increase the HTTP timeout settings. Check the official documentation for additional troubleshooting.
Running a Container#
To create and start a container named mysql-container using Ubuntu:
sudo docker run --name mysql-container -it ubuntuBreakdown of the command:
--name→ Specifies the container name-it→ Opens an interactive terminalubuntu→ The image we downloaded
Now, you’re inside the container’s shell and can configure it as needed.
Managing Docker Containers#
Restarting and Accessing Containers#
If you exit the container or restart your system, you can start and access your container again:
sudo docker start mysql-container
sudo docker exec -it mysql-container bashChecking Running Containers#
To check the status, uptime, or container ID, use:
sudo docker ps -aChecking Ports#
To see which ports are listening inside your container, install net-tools:
pacman -S net-toolsNote: Do not use
sudoinside the container, as you already have elevated permissions.
Stopping and Removing Containers#
Stop a Running Container:#
sudo docker stop container_id_or_nameRemove a Container:#
sudo docker rm container_id_or_nameRemove Multiple Containers at Once:#
sudo docker rm container_id1 container_id2 Conclusion#
Docker simplifies application deployment and management. Follow these steps to set up Docker on Arch Linux and start exploring its capabilities. 🚀
📌 Note: This guide is tailored for Arch Linux. If you’re using another distro, adjust the installation steps accordingly.
📌 Additional Resources#
🎥 Watch this Docker guide on YouTube
✍ Haris
📌 GitHub: https://github.com/Zenvila
📌 LinkedIn: https://www.linkedin.com/in/haris-shahzad-7b8746291/
📌 Member: COLAB (Research Lab)
