Ingin memasang Docker di Ubuntu dengan cepat dan mudah? Dalam panduan singkat ini, kami akan menunjukkan cara menggunakan satu script instalasi untuk mengatur Docker di sistem Anda. Dengan pendekatan ini, Anda dapat menghindari konfigurasi manual yang rumit dan langsung memulai dengan Docker.
Gunakan perintah berikut untuk mengunduh dan menjalankan script instalasi Docker yang disediakan oleh Docker:
root@labs-wachid:~# curl -fsSL https://get.docker.com -o get-docker.sh root@labs-wachid:~# ls -l total 40 -rw-r--r-- 1 root root 21596 Aug 30 23:13 get-docker.sh -rwx------ 1 root root 11694 Aug 29 09:16 get_helm.sh drwx------ 3 root root 4096 Jun 20 2023 snap root@labs-wachid:~#
Test Dry run
root@labs-wachid:~# sudo sh ./get-docker.sh --dry-run # Executing docker install script, commit: 0d6f72e671ba87f7aa4c6991646a1a5b9f9dae84 apt-get update -qq >/dev/null DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ca-certificates curl >/dev/null install -m 0755 -d /etc/apt/keyrings curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" -o /etc/apt/keyrings/docker.asc chmod a+r /etc/apt/keyrings/docker.asc echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list apt-get update -qq >/dev/null DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null root@labs-wachid:~#
Menjalankan script instalasi docker
root@labs-wachid:~# sudo sh get-docker.sh # Executing docker install script, commit: 0d6f72e671ba87f7aa4c6991646a1a5b9f9dae84 + sh -c apt-get update -qq >/dev/null + sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ca-certificates curl >/dev/null + sh -c install -m 0755 -d /etc/apt/keyrings + sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" -o /etc/apt/keyrings/docker.asc + sh -c chmod a+r /etc/apt/keyrings/docker.asc + sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list + sh -c apt-get update -qq >/dev/null + sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null + sh -c docker version Client: Docker Engine - Community Version: 27.2.0 API version: 1.47 Go version: go1.21.13 Git commit: 3ab4256 Built: Tue Aug 27 14:15:13 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.2.0 API version: 1.47 (minimum version 1.24) Go version: go1.21.13 Git commit: 3ab5c7d Built: Tue Aug 27 14:15:13 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.21 GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0 ================================================================================ To run Docker as a non-privileged user, consider setting up the Docker daemon in rootless mode for your user: dockerd-rootless-setuptool.sh install Visit https://docs.docker.com/go/rootless/ to learn about rootless mode. To run the Docker daemon as a fully privileged service, but granting non-root users access, refer to https://docs.docker.com/go/daemon-access/ WARNING: Access to the remote API on a privileged Docker daemon is equivalent to root access on the host. Refer to the 'Docker daemon attack surface' documentation for details: https://docs.docker.com/go/attack-surface/ ================================================================================ root@labs-wachid:~#
Verifikasi Instalasi: Setelah proses instalasi selesai, verifikasi bahwa Docker telah terinstal dengan benar dengan menjalankan:
root@labs-wachid:~# docker version Client: Docker Engine - Community Version: 27.2.0 API version: 1.47 Go version: go1.21.13 Git commit: 3ab4256 Built: Tue Aug 27 14:15:13 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.2.0 API version: 1.47 (minimum version 1.24) Go version: go1.21.13 Git commit: 3ab5c7d Built: Tue Aug 27 14:15:13 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.21 GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0 root@labs-wachid:~#
Check service docker
root@labs-wachid:~# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2024-08-30 23:16:44 UTC; 2min 0s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 134955 (dockerd) Tasks: 8 Memory: 49.7M CPU: 655ms CGroup: /system.slice/docker.service └─134955 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Aug 30 23:16:37 labs-wachid systemd[1]: Starting Docker Application Container Engine... Aug 30 23:16:38 labs-wachid dockerd[134955]: time="2024-08-30T23:16:38.849437547Z" level=info msg="Starting up" Aug 30 23:16:38 labs-wachid dockerd[134955]: time="2024-08-30T23:16:38.883457666Z" level=info msg="detected 127.0.0.5> Aug 30 23:16:40 labs-wachid dockerd[134955]: time="2024-08-30T23:16:40.719021992Z" level=info msg="Loading containers> Aug 30 23:16:41 labs-wachid dockerd[134955]: time="2024-08-30T23:16:41.932418203Z" level=info msg="Loading containers> Aug 30 23:16:42 labs-wachid dockerd[134955]: time="2024-08-30T23:16:42.669455116Z" level=info msg="Docker daemon" com> Aug 30 23:16:42 labs-wachid dockerd[134955]: time="2024-08-30T23:16:42.669851330Z" level=info msg="Daemon has complet> Aug 30 23:16:44 labs-wachid systemd[1]: Started Docker Application Container Engine. Aug 30 23:16:44 labs-wachid dockerd[134955]: time="2024-08-30T23:16:44.228003716Z" level=info msg="API listen on /run> lines 1-21/21 (END) ^C root@labs-wachid:~#
Tambahkan Pengguna ke Grup Docker (Opsional): Agar dapat menjalankan Docker tanpa sudo
, tambahkan pengguna Anda ke grup Docker:
adminx@labs-wachid:~$ sudo usermod -aG docker $USER adminx@labs-wachid:~$
Agar perubahan grup diterapkan, diperlukan logout dan login kembali, atau restart sistem.
adminx@labs-wachid:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES adminx@labs-wachid:~$ adminx@labs-wachid:~$