-
-
Save samsulmaarif/dc5e633f2141e2e74e7c6c71b3479854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# materi presentasi | |
- virtualization | |
- contianer | |
- virt vs container | |
- what & why docker? | |
https://docs.google.com/presentation/d/1pE-7hoURxkZ2DSlFc-ULLkTsU4MmcvEyZruyCOVIRxE/edit?usp=sharing | |
# buat akun docker hub | |
https://hub.docker.com/ | |
# chroot | |
mkdir -p /var/jail/{dev,etc,lib,lib64,usr,bin} | |
mkdir -p /var/jail/usr/bin | |
chown root.root /var/jail | |
buat /dev/null dengan perintah `mknod -m 666 /var/jail/dev/null c 1 3` | |
cd /var/jail/etc | |
cp /etc/ld.so.cache . | |
cp /etc/ld.so.conf . | |
cp /etc/nsswitch.conf . | |
cp /etc/hosts . | |
cd /var/jail/bin | |
cp /bin/ls . | |
cp /bin/bash . | |
ldd /bin/ls | |
cd /sbin | |
wget -O l2chroot http://www.cyberciti.biz/files/lighttpd/l2chroot.txt | |
chmod +x l2chroot | |
nano l2chroot | |
edit `BASE="/webroot" ke BASE="/var/jail"` | |
l2chroot /bin/ls | |
l2chroot /bin/bash | |
chroot /var/jail | |
ls | |
pwd | |
cp | |
exit | |
cd /var/jail | |
ls | |
cd bin | |
ls | |
which pwd | |
cp /bin/pwd . | |
which curl | |
cp /usr/bin/curl . | |
ldd /bin/pwd | |
ldd /usr/bin/curl | |
l2chroot /bin/pwd | |
l2chroot /usr/bin/curl | |
chroot /var/jail | |
# install docker debian | |
sudo su - | |
apt update | |
apt upgrade | |
apt install -y apt-transport-https ca-certificates curl software-properties-common gnupg2 | |
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
apt update | |
apt install docker-ce | |
docker version | |
# docker image | |
docker image ls | |
docker images | |
# pull image | |
docker pull [image] | |
# run container | |
docker run [nginx] | |
--name [nama container] | |
--rm | |
# container list | |
docker ps | |
docker container ls | |
# akses kedalam docker | |
docker exec [id container] bash | |
# expose port | |
-p port:port | |
# dockerfile | |
nano Dockerfile | |
``` | |
FROM ubuntu:18.04 | |
RUN apt update -y && apt install -y nginx | |
RUN echo "ini adit" > /var/www/html/index.html | |
EXPOSE 80 | |
ENTRYPOINT ["nginx", "-g", "daemon off;"] | |
``` | |
# build image | |
docker build -t [imagename] . | |
docker images | |
docker run [imagename] | |
docker container prune | |
# remove image | |
docker rmi [imagename] | |
nano index.html | |
``` | |
<html> | |
<head> | |
<title>Tefa Yadika - samsulmaarif</title> | |
</head> | |
<body> | |
<h1>latihan bikin docker image</h1> | |
<p>nama : samsulmaarif</p> | |
</body> | |
</html> | |
``` | |
nano Dockerfile | |
``` | |
FROM ubuntu:18.04 | |
RUN apt update -y && apt install -y nginx | |
COPY index.html /var/www/html/index.html | |
EXPOSE 80 | |
ENTRYPOINT ["nginx", "-g", "daemon off;"] | |
``` | |
# build ulang image-nya | |
docker build -t samsulmaarif/nginx:v2 . | |
docker run -dti --name=nginx2 -p 9002:80 samsulmaarif/nginx:v2 | |
http://[ip-host]:9002 | |
# docker volume | |
docker volume create latihan1-vol | |
docker volume ls | |
docker volume rm [volumename] | |
-v [volname]:path | |
docker exec -it [containername] bash | |
docker volume inspect [volname] | |
# docker hub | |
https://hub.docker.com | |
docker login | |
docker tag [image] [username]/[image] | |
docker push [image] | |
### Deploy WordPress | |
docker pull wordpres | |
docker pull mysql:5.7 | |
docker network create wp-network | |
docker run -dti --name=db -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=rahasia -e MYSQL_ROOT_PASSWORD=rahasia --network wp-network mysql:5.7 | |
docker run -dti -p 9005:80 --network wp-network --name=wordpress -e WORDPRESS_DB_HOST=db:3306 -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=rahasia -e WORDPRESS_DB_NAME=wordpress wordpress | |
## Docker Compose | |
Install docker-compose | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
nano docker-compose.yml | |
``` | |
version: '3.1' | |
services: | |
wordpress: | |
image: wordpress | |
restart: always | |
ports: | |
- 9007:80 | |
environment: | |
WORDPRESS_DB_HOST: db | |
WORDPRESS_DB_USER: wordpress | |
WORDPRESS_DB_PASSWORD: rahasia | |
WORDPRESS_DB_NAME: wordpress | |
volumes: | |
- wordpress:/var/www/html | |
db: | |
image: mysql:5.7 | |
restart: always | |
environment: | |
MYSQL_DATABASE: wordpress | |
MYSQL_USER: wordpress | |
MYSQL_PASSWORD: rahasia | |
MYSQL_RANDOM_ROOT_PASSWORD: '1' | |
volumes: | |
- db:/var/lib/mysql | |
volumes: | |
wordpress: | |
db: | |
``` | |
docker-compose up | |
## Docker Machine | |
### install virtualbox | |
wget wget https://download.virtualbox.org/virtualbox/6.1.0/VirtualBox-6.1.0-135406-Linux_amd64.run | |
chmod +x VirtualBox-6.1.0-135406-Linux_amd64.run | |
sudo ./VirtualBox-6.1.0-135406-Linux_amd64.run | |
### install docker-machine | |
curl -L https://github.com/docker/machine/releases/download/v0.13.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine | |
chmod +x /tmp/docker-machine | |
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine | |
docker-machine create test1 | |
docker-machine ls | |
docker-machine env test1 | |
eval $(docker-machine env test1) | |
env | grep DOCKER | |
docker images | |
docker ps -a | |
for e in {1..3}; do docker-machine create yadika$e; done | |
docker-machine ip yadika1 | |
docker-machine ssh yadika1 | |
docker swarm init --advertise-addr [ip-address-yadika1] | |
exit | |
docker-machine ssh yadika2 | |
docker swarm join --token [token] [ip-address-yadika1]:2377 | |
exit | |
docker-machine ssh yadika3 | |
docker swarm join --token [token] [ip-address-yadika1]:2377 | |
exit | |
docker-machine ssh yadika1 | |
docker node ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment