LAB DOCKER ADMINISTRATION AND TUNNELING
OS : Ubuntu 18.04
Size VM : Standard B4ms (4 vcpus, 16 GiB memory)
PENGENALAN DOCKER :
#1. Instal Docker
sudo apt update
sudo apt -y install docker.io
sudo systemctl status docker
#2. Menampilkan versi docker
sudo docker version
#3. Menampilkan detil instalasi docker
sudo docker info
#4. Uji instalasi docker
sudo docker run hello-world
#5. Menampilkan image yang sudah didownload
sudo docker image ls
#6. Menampilkan semua container (active ataupun exit)
sudo docker container ls -a
DOCKER PULL :
#1. Buka Docker Hub
#2. Search image Nginx yang ingin di Pull
#3. Pull Image dari Docker Hub
sudo docker pull nginx:latest
#4. Cek Image yang sudah di pull
sudo docker image ls
#5. Buat Container dengan image yang sudah di pull
sudo docker run -d -p 8080:80 --name nginxserver1 nginx:latest
#6. Cek container
sudo docker container ls -a
#7. Jalankan Container
sudo docker container start [container ID]
#8. Cek container
sudo docker container ls
#9 Cek pada browser
http://ipaddressazure:8181/
DOCKERFILE :
#1. Buat direktori /latihan/latihan01 dan masuk ke dalamnya
sudo mkdir -p /latihan/latihan01
cd /latihan/latihan01
#2. Buat file Dockerfile
Sudo vim Dockerfile
Tambahkan :
# Use whalesay image as a base image
FROM docker/whalesay:latest
# Install fortunes
RUN apt -y update && apt install -y fortunes
# Execute command
CMD /usr/games/fortune -a | cowsay
#3. Bangun image dari Dockerfile
sudo docker build -t docker-whale .
#4. Tampilkan image yang sudah dibangun
sudo docker image ls
#5. Uji jalankan image
sudo docker run docker-whale
DOCKER COMPOSE:
#1. Unduh Compose
sudo curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
#2. Set permisson executable
sudo chmod +x /usr/local/bin/docker-compose
#3. Uji instalasi
sudo docker-compose –version
#4. Buat direktori my_wordpress dan masuk ke direktori tersebut
Sudo mkdir /latihan/my_wordpress
cd /latihan/my_wordpress
#5. Buat file docker-compose.yml
Sudo vim docker-compose.yml
version: '3.2'
services:
db:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: vassameta
MYSQL_PASSWORD: rahasia
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: vassameta
WORDPRESS_DB_PASSWORD: rahasia
volumes:
dbdata:
#6. Jalankan compose
sudo docker-compose up -d
#7. Tampilkan daftar container
sudo docker container ls
#8. Uji browsing
http://ip server:8000
#9. Tunnel agar bisa dijalankan localhost
buka cmd pada windows.
"ssh -L port local:ip server:port docker username@ip server azzure"
ssh -L 8888:52.187.108.36:8000 docker@52.187.108.36
#10. Uji browsing dengan localhost
http://localhost:8888
#11. Hapus container, default network dan database wordpress
sudo docker-compose down --volumes
Komentar
Posting Komentar