Skip to content

Docker Lab 3

Before

Jika ini lab pertama anda

git clone -b lab_start https://github.com/arrow2601/Docker_Lab.git
cd Docker_Lab
bash docker_start_lab.sh
Jika ini bukan lab pertama anda
cd Docker_Lab
git pull
bash docker_start_lab.sh

Practice I

  1. Search image nginx
     docker search nginx
    
  2. Running image nginx image with the name nginx1 and expose port 8080
     docker run -d --name nginx1 -p 8080:80 nginx
    
  3. Display a decription of the nginx1 container
     docker inspect nginx1
    
  4. Running an nginx image with the name nginx2 and expose port 8081
     docker run -d --name nginx2 -p 8081:80 nginx
    
  5. Display container
     docker ps -a
     docker container ls -a
    
  6. Check nginx output on containers
     curl localhost:8080
     curl localhost:8081
    
  7. Accessing the container
     docker exec -it nginx2 /bin/bash
    
  8. Update and install editor on the container
    apt-get update -y && apt-get install nano -y
    
  9. edit index.html and move index.html to default directory nginx
    nano index.html
    
    <html>
    <body>
    MR. DIY
    </body>
    </html>
    
    mv index.html /usr/share/nginx/html
    
  10. Restart service nginx
    service nginx restart
    
  11. Rerun the container
    docker start nginx2
    
  12. Display a description of the container
    docker inspect nginx1
    docker inspect nginx2
    
  13. Check nginx output on containers
    curl localhost:8080
    curl localhost:8081
    
  14. Display the log content of the container
    docker logs nginx1
    docker logs nginx2
    
  15. DIsplay a description of the container
    docker inspect nginx1
    docker inspect nginx2
    
  16. Display the live resources used in the container
    docker stats nginx1
    docker stats nginx2
    
  17. Display running process in container
    docker top nginx1
    docker top nginx2
    

Practice II

  1. Search image ubuntu on Dockerhub
    docker search ubuntu
    
  2. Pull image ubuntu from Dockerhub
    docker pull ubuntu
    
  3. Running ubuntu container and access to the console
    docker run -it --name ubuntu1 ubuntu
    exit
    
  4. Run the ubuntu container and delete it when exiting the container.
    docker run -it --rm --name ubuntu2 ubuntu
    Exit the container with Ctrl+D or exit
    

Finish

untuk grading lab masukkan perintah docker-lab-3-grade Untuk keluar dari lab exit kemudian cek di browser http://89.116.134.157/index.php