Linux serverlarga Docker o'rnatish
Ubuntu serverlar uchun docker o'rnatish
Docker Engine-ni yangi host machinega birinchi marta o'rnatishdan oldin Docker repozitoriysini sozlashingiz kerak. Shundan so'ng siz Docker-ni repositorydan o'rnatishingiz va yangilashingiz mumkin.
1-> Repozitoriyani sozlash. apt
paketi indeksini yangilang va aptga HTTPS orqali repositoriyadan foydalanishga ruxsat berish uchun paketlarni o'rnating:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
2-> Dockerning rasmiy GPG kalitini qo'shing:
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
3-> Repositoriyani sozlash uchun quyidagi buyruqdan foydalaning:
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
4-> apt
paketi indeksini yangilang:
sudo apt-get update
5-> Docker Engine, containerd va Docker Compose-ni o'rnating.
Eng so'nggi versiyani(latest) o'rnatish uchun quyidagilarni bajaring:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y
6-> devops-journey-uz
docker imageni ishga tushirish orqali Docker Engine muvaffaqiyatli o'rnatilganini tekshiring:
sudo docker run -d -p 3000:3000 --name devops-journey --restart always devopsjourneyuz/devops-journey-uz:latest
DevOps Journey platformasi 3000
portda ishga tushadi.
Bu buyruq devopsjourneyuz:latest imageni yuklaydi va uni containerda ishga tushiradi. Container ishga tushganda, u tasdiqlash xabarini chop etadi va chiqadi. Agar serveringizda 3000
portda DevOps Journey platformasi ishlab turgan bo'lsa, tabriklaymiz siz Docker Engine-ni muvaffaqiyatli o'rnatdingiz va ishga tushirdingiz.
rootsiz ishlashga urinayotganda xatoliklarni qabul qilyapsizmi? Docker foydalanuvchilari guruhi mavjud, lekin foydalanuvchilarni o'z ichiga olmaydi, shuning uchun siz Docker buyruqlarini bajarish uchun sudo-dan foydalanishingiz kerak. Imtiyozli bo'lmagan foydalanuvchilarga Docker buyruqlarini va boshqa ixtiyoriy konfiguratsiya bosqichlarini bajarishga ruxsat berish uchun quyidagilarni bajarishingiz kerak.
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
sudo chown $USER:docker /var/run/docker.sock
docker info
Debian serverlarga docker o'rnatish.
Docker Engine-ni yangi host machinega birinchi marta o'rnatishdan oldin Docker repozitoriysini sozlashingiz kerak. Shundan so'ng siz Docker-ni repositorydan o'rnatishingiz va yangilashingiz mumkin.
Talablar
OS talablari
Docker Engine-ni o'rnatish uchun sizga ushbu Debian versiyalaridan birining 64 bitli versiyasi kerak bo'ladi:
- Debian Bookworm 12 (stable)
- Debian Bullseye 11 (oldstable)
Debian uchun Docker Engine x86_64
(yoki amd64
), armhf
, arm64
va ppc64le
(ppc64el
) arxitekturalari bilan mos keladi.
1-> Repozitoriyani sozlash. apt
paketi indeksini yangilang va aptga HTTPS orqali repositoriyadan foydalanishga ruxsat berish uchun paketlarni o'rnating:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
2-> Dockerning rasmiy GPG kalitini qo'shing:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
3-> Repositoriyani sozlash uchun quyidagi buyruqdan foydalaning:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
4-> apt
paketi indeksini yangilang:
sudo apt-get update
5-> Docker Engine, containerd va Docker Compose-ni o'rnating.
Eng so'nggi versiyani(latest) o'rnatish uchun quyidagilarni bajaring:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y
CentOS-ga Docker Engine o'rnatish
CentOS-da Docker Engine bilan ishlashni boshlash uchun talab shartlarga javob berganingizga ishonch hosil qiling va keyin o'rnatish bosqichlarini bajaring.
Talablar OS talablari
Docker Engine-ni o'rnatish uchun sizga quyidagi CentOS versiyalaridan birining maintained versiyasi kerak bo'ladi:
- CentOS 7
- CentOS 8 (stream)
- CentOS 9 (stream)
rpm
repositoriya yordamida o'rnatish. Docker Engine-ni yangi serverga birinchi marta o'rnatishdan oldin Docker repozitoriyasini sozlashingiz kerak. Shundan so'ng siz Docker-ni repositoriyadan o'rnatishingiz va yangilashingiz mumkin.
1-> Repozitoriyani sozlash yum-utils
paketini o'rnating (yum-config-manager
yordam dasturini taqdim etadi) va repositoriyani sozlang.
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2-> Docker Engine, containerd va Docker Compose-ni o'rnatish.
Eng so'nggi versiyani(latest) o'rnatish uchun quyidagilarni bajaring:
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
Agar GPG kalitini(GPG key) qabul qilish so'ralsa, fingerprint 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
ga mos kelishini tekshiring va agar shunday bo'lsa, uni qabul qiling.
Bu buyruq Docker-ni o'rnatadi, lekin u Docker-ni ishga tushirmaydi. Shuningdek, u docker guruhini(group) yaratadi, ammo u default bo'yicha guruhga hech qanday foydalanuvchi qo'shmaydi.
3-> Docker-ni ishga tushiring.
sudo systemctl start docker
sudo systemctl enable docker
4-> devops-journey-uz
docker imageni ishga tushirish orqali Docker Engine muvaffaqiyatli o'rnatilganini tekshiring:
sudo docker run -d -p 3000:3000 --name devops-journey --restart always devopsjourneyuz/devops-journey-uz:latest
DevOps Journey platformasi 3000
portda ishga tushadi.
Bu buyruq devopsjourneyuz:latest imageni yuklaydi va uni containerda ishga tushiradi. Container ishga tushganda, u tasdiqlash xabarini chop etadi va chiqadi. Agar serveringizda 3000
portda DevOps Journey platformasi ishlab turgan bo'lsa, tabriklaymiz siz Docker Engine-ni muvaffaqiyatli o'rnatdingiz va ishga tushirdingiz.
Docker Engineni yangilash
Ushbu misol https://get.docker.com/ (opens in a new tab) dan skriptni yuklab oladi va uni Linuxda Dockerning so'nggi barqaror versiyasini o'rnatish uchun ishga tushiradi:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Pre-releaselarni o'rnatish test Beta versiyalar
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh
Docker Engine-ni o'chirib tashlash
1-> Docker Engine, CLI, containerd va Docker Compose paketlarini olib tashlash:
Ubuntu uchun
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
CentOS uchun
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
2-> Serveringizdagi imagelar, containerlar, volumelar yoki custom configuratsiya fayllari avtomatik ravishda o'chirilmaydi. Barcha imagelar, containerlar va volumelarni o'chirish uchun:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
Qo'shimcha
Foydalanilgan manbalar: docs.docker.com (opens in a new tab)
Sana: 2023.11.19(2023-yil 19-noyabr)
Oxirgi yangilanish: 2024.05.16(2024-yil 16-may)
Muallif: Otabek Ismoilov
Telegram (opens in a new tab) | Github (opens in a new tab) | LinkedIn (opens in a new tab) |
---|