Welcome to Armbian 23.02.2 Focal with Linux 5.15.100 No end-user support: untested automated build & unsupported (focal) userspace! System load: 86% Up time: 9:05 Local users: 2 Memory usage: 12% of 1.77G IP: 192.168.1.241 172.24.151.112 CPU temp: 56°C Usage of /: 39% of 7.0G [ 116 security updates available, 153 updates total: apt upgrade ] Last check: 2023-07-30 08:07 Last login: Sun Jul 30 15:45:53 2023 from 192.168.1.230 .-/+oossssoo+/-. xcozy@xcozy `:+ssssssssssssssssss+:` ----------- -+ssssssssssssssssssyyssss+- OS: Armbian (23.02.2) aarch64 .ossssssssssssssssssdMMMNysssso. Host: Amlogic Meson GXL (S905X) P212 Development Board /ssssssssssshdmmNNmmyNMMMMhssssss/ Kernel: 5.15.100 +ssssssssshmydMMMMMMMNddddyssssssss+ Uptime: 9 hours, 5 mins /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Packages: 1573 (dpkg) .ssssssssdMMMNhsssssssssshNMMMdssssssss. Shell: bash 5.0.17 +sssshhhyNMMNyssssssssssssyNMMMysssssss+ Resolution: 1920x1080 ossyNMMMNyMMhsssssssssssssshmmmhssssssso Theme: Adwaita [GTK3] ossyNMMMNyMMhsssssssssssssshmmmhssssssso Icons: Adwaita [GTK3] +sssshhhyNMMNyssssssssssssyNMMMysssssss+ Terminal: /dev/pts/2 .ssssssssdMMMNhsssssssssshNMMMdssssssss. CPU: (4) @ 1.512GHz /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/ Memory: 264MiB / 1811MiB +sssssssssdmydMMMMMMMMddddyssssssss+ /ssssssssssshdmNNNNmyNMMMMhssssss/ .ossssssssssssssssssdMMMNysssso. -+sssssssssssssssssyyyssss+- `:+ssssssssssssssssss+:` .-/+oossssoo+/-. xcozy@xcozy:~$
Docker has revolutionized the way developers create, deploy, and manage applications by enabling lightweight containerization technology, which allows for easy management and isolation of applications and their dependencies. In this tutorial, we will guide you through the process of installing Docker on Ubuntu 22.04, the latest long-term support (LTS) release of this popular Linux distribution. We will begin by discussing the benefits of using Docker and why it is essential for modern development workflows. Next, we will cover the necessary system requirements and prerequisites for a successful installation.
Prerequisites
Before we begin, ensure that you have:
- A system running Ubuntu 22.04.
- A user account with sudo privileges.
Step 1: Update your system
Before installing any new software, it’s always a good idea to update your system packages. Open the terminal and run the following commands:
sudo apt update && sudo apt upgrade
root@xcozy:~# sudo apt update && sudo apt upgrade Hit:1 http://download.zerotier.com/debian/focal focal InRelease Hit:3 http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu focal InRelease Hit:4 http://ports.ubuntu.com focal InRelease ..... ..... Processing triggers for dbus (1.12.16-2ubuntu2.3) ... Processing triggers for shared-mime-info (1.15-1) ... Processing triggers for initramfs-tools (0.136ubuntu6.7) ... update-initramfs: Not updating initramfs. Processing triggers for ca-certificates (20230311ubuntu0.20.04.1) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. root@xcozy:~#
Step 2: Install required dependencies
To install Docker on Ubuntu, we need to install some necessary dependencies first. Run the following command to install them
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Hasil output sebagai berikut :
root@xcozy:~# sudo apt install apt-transport-https ca-certificates curl software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done ca-certificates is already the newest version (20230311ubuntu0.20.04.1). curl is already the newest version (7.68.0-1ubuntu2.19). software-properties-common is already the newest version (0.99.9.11). The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 1.704 B of archives. After this operation, 162 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://ports.ubuntu.com focal-updates/universe arm64 apt-transport-https all 2.0.9 [1.704 B] Fetched 1.704 B in 1s (2.896 B/s) Selecting previously unselected package apt-transport-https. (Reading database ... 166014 files and directories currently installed.) Preparing to unpack .../apt-transport-https_2.0.9_all.deb ... Unpacking apt-transport-https (2.0.9) ... Setting up apt-transport-https (2.0.9) ... root@xcozy:~#
Step 3: Add Docker repository
Next, we will add the official Docker repository to our system. First, add the GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Hasil output :
root@xcozy:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg root@xcozy:~#
Then, add the Docker repository to your system with the following command:
echo "deb [arch=$(dpkg --print-architecture) 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
Hasil output :
root@xcozy:~# echo "deb [arch=$(dpkg --print-architecture) 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
Step 4: Install Docker
Now that we have added the Docker repository, update your package index:
sudo apt update
root@xcozy:~# sudo apt update Hit:1 http://download.zerotier.com/debian/focal focal InRelease Hit:2 http://ports.ubuntu.com focal InRelease Hit:3 http://ports.ubuntu.com focal-security InRelease Hit:4 http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu focal InRelease Get:6 https://download.docker.com/linux/ubuntu focal InRelease [57,7 kB] Hit:7 http://ports.ubuntu.com focal-updates InRelease Hit:8 http://ports.ubuntu.com focal-backports InRelease Hit:9 http://ppa.launchpad.net/saiarcot895/chromium-dev/ubuntu focal InRelease Get:5 http://mirror.ossplanet.net/armbian/apt focal InRelease [52,4 kB] Get:10 https://download.docker.com/linux/ubuntu focal/stable arm64 Packages [36,7 kB] Get:11 http://mirror.ossplanet.net/armbian/apt focal/main armhf Packages [460 kB] Get:12 http://mirror.ossplanet.net/armbian/apt focal/main arm64 Packages [803 kB] Get:13 http://mirror.ossplanet.net/armbian/apt focal/main all Packages [90,0 kB] Fetched 1.500 kB in 6s (259 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. root@xcozy:~#
Then, install Docker with the following command:
sudo apt install docker-ce docker-ce-cli containerd.io
Hasil output sebagai berikut :
root@xcozy:~# sudo apt install docker-ce docker-ce-cli containerd.io Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: cgroupfs-mount | cgroup-lite Recommended packages: apparmor docker-ce-rootless-extras pigz docker-buildx-plugin docker-compose-plugin The following NEW packages will be installed: containerd.io docker-ce docker-ce-cli 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 46,3 MB of archives. After this operation, 201 MB of additional disk space will be used. Get:1 https://download.docker.com/linux/ubuntu focal/stable arm64 containerd.io arm64 1.6.21-1 [20,3 MB] Get:2 https://download.docker.com/linux/ubuntu focal/stable arm64 docker-ce-cli arm64 5:24.0.5-1~ubuntu.20.04~focal [12,0 MB] Get:3 https://download.docker.com/linux/ubuntu focal/stable arm64 docker-ce arm64 5:24.0.5-1~ubuntu.20.04~focal [14,0 MB] Fetched 46,3 MB in 15s (3.033 kB/s) Selecting previously unselected package containerd.io. (Reading database ... 166018 files and directories currently installed.) Preparing to unpack .../containerd.io_1.6.21-1_arm64.deb ... Unpacking containerd.io (1.6.21-1) ... Selecting previously unselected package docker-ce-cli. Preparing to unpack .../docker-ce-cli_5%3a24.0.5-1~ubuntu.20.04~focal_arm64.deb ... Unpacking docker-ce-cli (5:24.0.5-1~ubuntu.20.04~focal) ... Selecting previously unselected package docker-ce. Preparing to unpack .../docker-ce_5%3a24.0.5-1~ubuntu.20.04~focal_arm64.deb ... Unpacking docker-ce (5:24.0.5-1~ubuntu.20.04~focal) ... Setting up containerd.io (1.6.21-1) ... Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service. Setting up docker-ce-cli (5:24.0.5-1~ubuntu.20.04~focal) ... Setting up docker-ce (5:24.0.5-1~ubuntu.20.04~focal) ... Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service. Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket. Processing triggers for man-db (2.9.1-1) ... Processing triggers for systemd (245.4-4ubuntu3.22) ... root@xcozy:~#
Step 5: Verify Docker installation
To verify that Docker has been installed successfully, run the following command:ADVERTISEMENT
sudo docker --version
You should see output similar to this, indicating the installed Docker version:
root@xcozy:~# sudo docker --version Docker version 24.0.5, build ced0996 root@xcozy:~#
Step 6: Manage Docker service
Docker should now be installed and running as a background service. To check the status of the Docker service, run:
sudo systemctl status docker
Hasil output :
root@xcozy:~# sudo systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2023-07-30 16:17:12 WIB; 1min 17s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 26834 (dockerd) Tasks: 10 Memory: 27.3M CGroup: /system.slice/docker.service └─26834 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Jul 30 16:17:11 xcozy systemd[1]: Starting Docker Application Container Engine... Jul 30 16:17:11 xcozy dockerd[26834]: time="2023-07-30T16:17:11.381792553+07:00" level=info msg="Starting up" Jul 30 16:17:11 xcozy dockerd[26834]: time="2023-07-30T16:17:11.557488489+07:00" level=info msg="Loading containers: start." Jul 30 16:17:12 xcozy dockerd[26834]: time="2023-07-30T16:17:12.150742174+07:00" level=info msg="Loading containers: done." Jul 30 16:17:12 xcozy dockerd[26834]: time="2023-07-30T16:17:12.239057604+07:00" level=info msg="Docker daemon" commit=a61e2b4 graphdriver=overlay2 version=24.0.5 Jul 30 16:17:12 xcozy dockerd[26834]: time="2023-07-30T16:17:12.239820902+07:00" level=info msg="Daemon has completed initialization" Jul 30 16:17:12 xcozy dockerd[26834]: time="2023-07-30T16:17:12.373258243+07:00" level=info msg="API listen on /run/docker.sock" Jul 30 16:17:12 xcozy systemd[1]: Started Docker Application Container Engine. root@xcozy:~#
If the Docker service is not running, you can start it with:
sudo systemctl start docker
To enable the Docker service to start automatically at boot, run:
sudo systemctl enable docker
Hasil output sebagai berikut :
root@xcozy:~# sudo systemctl enable docker Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable docker root@xcozy:~#
Step 7: Running Docker without sudo (optional)
By default, Docker requires sudo privileges to run. If you want to use Docker without typing ‘sudo’ every time, add your user to the ‘docker’ group with the following command:
sudo usermod -aG docker $USER
Untuk menjalankan perintah, harus keluar dulu dari root atau ganti $USER dengan nama user yang di kehendaki
masadmin@xcozy:~$ sudo usermod -aG docker $USER
Pengecekan group
masadmin@xcozy:~$ cat /etc/group
After running this command, log out and log back in for the changes to take effect.
Conclusion
Congratulations! You have successfully installed Docker on your Ubuntu 22.04 system. You can now start using Docker to create, deploy, and manage your containerized applications. For more information on using Docker and its features, visit the official Docker documentation: https://docs.docker.com/.