Lab 4.1: Exploring Dockerfile - Part 1

Dockerfile (latihan01)

1. Clone repository Node

git clone https://github.com/spkane/docker-node-hello.git \
    --config core.autocrlf=input latihan01

2. Masuk ke dalam direktori

cd latihan01

3. Buat image

docker build -t node-latihan01 .

4. Buat container

docker run -d --rm --name node-latihan01 -p 8080:8080 node-latihan01

5. Coba akses port. [screenshot-4-1-5]

curl localhost:8080

6. Hapus image dan container

docker stop node-latihan01
docker rm node-latihan01
docker rmi node-latihan01

Dockerfile (latihan02)

1. Buat direktori latihan02

cd $HOME
mkdir latihan02
cd latihan02

2. Buat file Dockerfile. [screenshot-4-1-3]

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

docker build -t docker-whale .

4. Tampilkan image yang sudah dibangun. [screenshot-4-1-4]

docker image ls

5. Uji jalankan image

docker run docker-whale

6. Menampilkan container. [screenshot-4-1-6]

docker ps
docker container ls -a

7. Hapus semua container

Daftar Materi