-
Notifications
You must be signed in to change notification settings - Fork 2
/
catetan-glibdocker.txt
129 lines (85 loc) · 2.56 KB
/
catetan-glibdocker.txt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
##########################
##### Install 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
##########################
##### whalesay image #####
##########################
#1. Buka Docker Hub dan cari image whalesay
https://hub.docker.com
#2. Jalankan image whalesay
sudo docker run docker/whalesay cowsay boo
#3. Tampilkan image yang sudah didownload
sudo docker image ls
#4. Tampilkan semua container (upataupun exit)
sudo docker container ls -a
##################################
##### Dockerfile (latihan01) #####
##################################
#1. Buat direktori /latihan/latihan01 dan masuk ke dalamnya
mkdir -p latihan/latihan01
cd latihan/latihan01
#2. Buat file Dockerfile
vim Dockerfile
# 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
###################################
##### Dockerizing Application #####
###################################
#0. Install git
sudo apt install -y git
cd ~
#1. Clone repo berikut
git clone https://github.com/sdmoko/2048.git
#2. Pindah direktori
cd 2048
#3. Buat Dockerfile
vim Dockerfile
#4. Isi dockerfile
#FROM is the base image for which we will run our application
FROM nginx:latest
# Copy files and directories from the application
COPY index.html /usr/share/nginx/html
COPY favicon.ico /usr/share/nginx/html
COPY Rakefile /usr/share/nginx/html
COPY style/ /usr/share/nginx/html/style/
COPY meta/ /usr/share/nginx/html/meta/
COPY js/ /usr/share/nginx/html/js/
# Redirect log
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
# Tell Docker we are going to use this port
EXPOSE 80
STOPSIGNAL SIGTERM
# Run nginx apps
CMD ["nginx", "-g", "daemon off;"]
#4. Build image
sudo docker build -t [NAMA-IMAGE] .
#5. Running image
sudo docker run -d --name [NAMA-CONTAINER] -p 8000:80 [NAMA-IMAGE]
#6. Cek hasil run docker
curl http://localhost:8000
browsing ke ip-address:8000