انتقل إلى المحتوى

الدروس الخوادم متوسط1 دقائق قراءة

How to Install Docker and Docker Compose on Ubuntu

Install Docker Engine and the Compose plugin on Ubuntu from Docker's official repository, run your first container and manage it without sudo.

بواسطة فريق تحرير ZSOLNET آخر تحديث

هذه الصفحة غير متاحة بالعربية بعد، لذا تُعرض بالإنجليزية.

أهم النقاط

  • Install Docker from Docker's own repository for current versions.
  • Compose is now a plugin: docker compose (with a space).
  • Docker can bypass UFW rules for published ports — publish only what you need.

1. Add Docker’s repository

sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
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

2. Install Docker Engine and Compose

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world

3. Run Docker without sudo (optional)

sudo usermod -aG docker $USER

Log out and back in for the change to apply.

4. A first Compose file

# compose.yaml
services:
  web:
    image: nginx:stable
    ports:
      - "8080:80"
    restart: unless-stopped

Start it with docker compose up -d and visit http://your-server-ip:8080.

الأسئلة الشائعة

Is the docker group safe?

Members of the docker group effectively have root access to the host. Only add trusted users.

Why can the internet reach a port I blocked with UFW?

Docker writes its own iptables rules for published ports. Bind internal services to 127.0.0.1 (for example 127.0.0.1:5432:5432) or don't publish them at all.

شارك X LinkedIn Facebook

الدخول إلى حسابك

أدِر نطاقاتك واستضافتك وفواتيرك من مكان واحد.

اتصال آمن مباشرة مع منطقة العملاء في ZSOLNET.

افتح لوحة تحكم ZSOLNET

ليس لديك حساب؟