image

In this lab we will practice, command to operate docker contianer

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

Run a docker container with image nginx and expose port 80 as 8080

Solution
docker run -p 8080:80 nginx

List all docker containers

Solution
docker container ls -a

Start container from previous step

Solution
docker start <container id>

Stop container from previous step

Solution
docker stop <container id>

Run a docker container with image nginx and expose port 80 as 8080 and name it app1

Solution
docker run --name app1 -d -p 8080:80 nginx

Check logs from docker container we created in previous step

Solution
docker logs app1
docker logs -f app1

Restart container from previous step

Solution
docker restart app1

Check process running inside docker container we created in privous steps

Solution
docker top app1

Kill container from previous step

Solution
docker kill app1

Remove container from previous step

Solution
docker rm app1
docker rm  -f app1

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