image

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

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

image

Open Play with Docker

image

login with your docker hub account.

image

Click on start

image

It will start a 4 hr session

image

click on + ADD NEW INSTANCE

image

Create Dockerfile to create docker image

Solution
vi Dockerfile
FROM ubuntu

RUN apt-get update  

RUN apt-get install figlet  

CMD ["figlet", "hello docker"]  

Build docker image with Dockerfile from previous step

Solution
docker image build -t imageformfile:0.1 .

Run docker container with image build in previous step

Solution
docker container run imageformfile:0.1

List all docker images

Solution
docker image ls -a

List all all changes made to docker image Use image from previous step

Solution
docker image history <image ID>

Update you docker iamge with 0.2

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

Build docker image with updated Dockerfile from previous step update tag to 0.2

Solution
docker image build -t imageformfile:0.2 .

Run docker container with image build in previous step

Solution
docker container run imageformfile:0.2

Delete all three nodes and close session

  1. click on first node and then DELETE
  2. Repeat same for second and third node
  3. click close session

image

Congratulations you have completed this lab

Let us know if you still have any question
Youtube video for this lab