sebelumnya saya menginstall docker ini di ubuntu 16.04 yang saya deploy diatas (OPENSTACK), hasilnya cukup bagus belum ada masalah
untuk menginstall docker di ubuntu ini sebenarnya cukup sederhana, seperti berikut dengan login mengunakan root
- update dan upgrade ubuntu
1 |
apt update && apt upgrade |
- install apt transport https dan ca certificate
1 |
apt install apt-transport-https ca-certificates |
- tambahkan GPG key baru untuk repositori docker
1 2 |
apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 \ --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
- tamhkan repositori untuk docker (ubuntu xenial)
1 |
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | tee /etc/apt/sources.list.d/docker.list |
- kemudian update kembali
1 |
apt update |
- kemudian verifikasi repository yang sudah kita update sebelumnya
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
root@docker1-ubuntu:/home/ubuntu# apt-cache policy docker-engine docker-engine: Installed: (none) Candidate: 1.12.5-0~ubuntu-xenial Version table: 1.12.5-0~ubuntu-xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.4-0~ubuntu-xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.3-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.2-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.1-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.0-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.2-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.1-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.0-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages |
- kemudian install kernel tambahan
1 |
apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual |
- kemudian install docker-engine
1 |
root@docker1-ubuntu:/home/ubuntu# apt install docker-engine |
- kemudian restart / start service docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
root@docker1-ubuntu:/home/ubuntu# systemctl restart docker root@docker1-ubuntu:/home/ubuntu# 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 2016-12-30 18:21:32 UTC; 8s ago Docs: https://docs.docker.com Main PID: 24646 (dockerd) Tasks: 16 Memory: 17.1M CPU: 375ms CGroup: /system.slice/docker.service ├─24646 /usr/bin/dockerd -H fd:// └─24652 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-int Dec 30 18:21:31 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:31.770700924Z" level=info msg="Graph migration to content-addressability Dec 30 18:21:31 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:31.771928815Z" level=warning msg="Your kernel does not support swap memor Dec 30 18:21:31 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:31.773723733Z" level=info msg="Loading containers: start." Dec 30 18:21:31 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:31.787861659Z" level=info msg="Firewalld running: false" Dec 30 18:21:32 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:32.094487104Z" level=info msg="Default bridge (docker0) is assigned with Dec 30 18:21:32 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:32.230276165Z" level=info msg="Loading containers: done." Dec 30 18:21:32 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:32.231128331Z" level=info msg="Daemon has completed initialization" Dec 30 18:21:32 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:32.231578951Z" level=info msg="Docker daemon" commit=7392c3b graphdriver= Dec 30 18:21:32 docker1-ubuntu systemd[1]: Started Docker Application Container Engine. Dec 30 18:21:32 docker1-ubuntu dockerd[24646]: time="2016-12-30T18:21:32.269698001Z" level=info msg="API listen on /var/run/docker.sock" lines 1-22/22 (END) |
- kemudian kita coba untuk testing menjalankan image hello-world
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
root@docker1-ubuntu:/home/ubuntu# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world c04b14da8d14: Pull complete Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9 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. 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 Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ |
okee sudah berhasil, untuk installasi docker sebenarnya sudah selesai sampai sini, untuk selanjutnya kita akan coba menjalankan image docker yang lainnya dan memanag networknya
- kemudian saya akan membuat user alan pada docker
1 |
adduser alan |
kemudian isikan password sesuai kebutuhan anda, kemudian beri akses user non-root pada docker
1 |
root@docker1-ubuntu:/home/ubuntu# usermod -aG docker alan |
perintah diatas berfungsi untuk memberikan akses kepada user alan supaya dapat mengakses command docker yang secara default hanya bisa diakses oleh user root.
- Enable Memory dan SWAP
by default VM docker tidak bisa mengunakan swap pada host, itu kita bisa ketahui ketika menjalankan command docker info
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
root@docker1-ubuntu:/home/ubuntu# docker info Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 1 Server Version: 1.12.5 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 3 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: overlay null host bridge Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor seccomp Kernel Version: 4.4.0-57-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 992.3 MiB Name: docker1-ubuntu ID: SPNR:YAIY:MPVW:BJO2:CA5O:UOVI:5XXQ:VO6D:3TOZ:3TNN:6ENJ:RAK5 Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ WARNING: No swap limit support Insecure Registries: 127.0.0.0/8 |
paling bawah ada peringatan WARNING: No swap limit support, untuk mengatasi itu maka kita bisa melakukan seperti ini pada line 12
1 2 3 |
root@docker1-ubuntu:/home/ubuntu# nano /etc/default/grub GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" |
kemudian update-grup
1 2 3 4 5 |
root@docker1-ubuntu:/home/ubuntu# update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.4.0-57-generic Found initrd image: /boot/initrd.img-4.4.0-57-generic done |
kemudian reboot host dockernya, setalh itu kita cek lagi dengan docker info
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
root@docker1-ubuntu:/home/ubuntu# docker info Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 1 Server Version: 1.12.5 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 3 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: null overlay bridge host Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor seccomp Kernel Version: 4.4.0-57-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 992.3 MiB Name: docker1-ubuntu ID: SPNR:YAIY:MPVW:BJO2:CA5O:UOVI:5XXQ:VO6D:3TOZ:3TNN:6ENJ:RAK5 Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Insecure Registries: 127.0.0.0/8 |
dan hasilnya sudah tidak ada warning lagi, alhamdulillah berhasil
oke cukup sekian dulu tutorialnya semoga bermanfaat….
keep learning and istiqomah
System Engineer
Komentar