image

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

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

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

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

Solution
docker run -p 8080:80 nginx

Task: List all docker containers

Solution
docker container ls -a

Task: Start container from previous step

Solution
docker start <container id>

Task: Stop container from previous step

Solution
docker stop <container id>

Task: 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

Task: Check logs from docker container we created in previous step

Solution
docker logs app1
docker logs -f app1

Task: Restart container from previous step

Solution
docker restart app1

Task: Check process running inside docker container we created in previous steps

Solution
docker top app1

Task: Kill container from previous step

Solution
docker kill app1

Task: Remove container from previous step

Solution
docker rm app1
docker rm  -f app1

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
Click on ‘Submit Feedback’ on the bottom left of the page to submit any questions/feedback.