Cara Menginstall Docker, Docker merupakan sebuah platform terbuka yang dapat digunakan untuk mengembangkan, mendistribusikan dan menjalankan aplikasi pada lingkungan terisolasi yang disebut dengan container, dengan docker memungkinkan kita untuk memisahkan aplikasi dari infrastruktur, dengan begitu kita dapat men-deliver apliaksi dengan lebih cepat.
dengan docker anda dapat mengelola infrastruktur seperti halnya mengelola aplikasi, container sangat ringan berbeda halnya dengan virtual machine, namun docker container sangat bergantung pada kernel hostnya.
Docker memiliki 2 versi, versi enterprise dan versi komunitas, disini kita akan mencoba memasang versi komunitas pada distribusi CentOS dan Ubuntu.
Cara Menginstall Docker di CentOS 7
Daftar isi
jika anda sudah memasang docker versi lama silahkan hapus terlebih dahulu
$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
pasang paket yang dibutuhkan docker
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
disini kita akan memasang docker stable maka tambahkan repositori untuk docker stable
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
selanjutnya pasang docker dengan perintah berikut
$ sudo yum install docker-ce docker-ce-cli containerd.io

jalankan service docker dnegan perintah berikut
$ sudo systemctl start docker
lalu cek apakah service docker telah berjalan
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Sel 2019-07-30 14:40:30 UTC; 3s ago Docs: https://docs.docker.com Main PID: 11246 (dockerd) Tasks: 8 Memory: 53.5M CGroup: /system.slice/docker.service └─11246 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
lalu test docker dengan menjalankan container hello-world
$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
selamat, docker telah terinstall 🙂
Cara Install Docker di Ubuntu 18.04
jika anda telah memasang versi lama, silahkan hapus terlebih dahulu
$ sudo apt-get remove docker docker-engine docker.io containerd runc
pasang paket yang dibutuhkan untuk memasang docker
$ sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
tambahkan GPG key Docker
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
lalu tambahkan repository docker
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
selanjutnya pasang docker
$ sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
sampai tahap ini docker telah berhasil terpasang, selanjutnya kita coba dengan menjalankan container hello-world
$ sudo docker run hello-world