Dockerlab 104 Creating Docker image with Dockerfile

access_time2 mins remaining
Dockerlab 104 Creating Docker image with Dockerfile

About this Lab

subjectLast updated Oct 20, 2021
account_circleWritten by www.ShareLearn.net

1. Overview

docker lab 104}}

In this lab, we will be creating docker image with dockerfile and run a container using it

2. Demo

In case you prefer a video, check below our YouTube video for this lab

3. Create docker hub account.

Create docker hub account. Docker Hub skip this step if you already have one

image

4. Open Play with docker

Open Play with Docker

image

login with your docker hub account.

imageClick on start play with docker startIt will start a 4 hr session play with kubernetes session

5. Add new instance

click on + ADD NEW INSTANCE

play with kubernetes node

6. Dockerfile

Task: Create a Dockerfile to create a docker image

Solution
vi Dockerfile
FROM ubuntu

RUN apt-get update  

RUN apt-get install figlet  

CMD ["figlet", "hello docker"]  

7. Build docker image

Task: Build docker image with Dockerfile from previous step

Solution
docker image build -t imageformfile:0.1 .

8. Run docker container

Task: Run docker container with image build in previous step

Solution
docker container run imageformfile:0.1

9. List docker images

Task: List all docker images on local system

Solution
docker image ls -a

10. Check docker images changes

Task: List all all changes made to docker image

Use image from previous step

Solution
docker image history <image ID>

11. Modify docker image

Update you docker image with 0.2

Solution
vi Dockerfile
CMD ["figlet", "hello docker 0.2"]  

12. Build docker image

TasK: Build docker image with updated Dockerfile from previous step

update tag to 0.2

Solution
docker image build -t imageformfile:0.2 .

13. Run docker container

Task: Run docker container with image build in previous step

Solution
docker container run imageformfile:0.2

14. Cleanup

Task: Delete all open nodes/instances and close session

  1. Select the node and click on DELETE
  2. Repeat same for any other open nodes
  3. click close session

cleanup}}


15. Conclusion

Click on ‘Submit Feedback’ on the bottom left of the page to submit any questions/feedback.
bug_report Submit feedback