Dockerlab 104 Creating Docker image with Dockerfile
About this Lab
subjectLast updated Oct 20, 2021
1. Overview
}}
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
4. Open Play with docker
Open Play with Docker

login with your docker hub account.



5. Add new instance
click on + ADD NEW INSTANCE
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
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
- Select the node and click on DELETE
- Repeat same for any other open nodes
- click close session
}}