image

In this lab we will create docker contianer by pulling docker image interact with it and create new docker container

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

pull below docker images

ubuntu
ubuntu:18.04
ubuntu:20.10
ubuntu:16.04
alpine
alpine:3.12.0
alpine:3.11.6
alpine:3.10
Solution
docker pull ubuntu

docker pull ubuntu:18.04
docker pull ubuntu:20.10
docker pull ubuntu:16.04
docker pull alpine
docker pull alpine:3.12.0
docker pull alpine:3.11.6
docker pull alpine:3.10

check docker images

Solution
 docker images

check all docker images

Solution
 docker images -a

check all docker images for ubuntu

Solution
docker images ubuntu

check all docker images with docker image command

Solution
docker image ls

run a docker container with image alpine and run command ls -la inside it

Solution
docker container run alpine ls -l

run a docker container with image alpine and run command echo “hello from alpine” inside it

Solution
docker container run alpine echo "hello from alpine"

run a docker container with image alpine and connect to its shell

Solution
docker container run alpine /bin/sh

run a docker container with image alpine and connect to its shell write to “hello world” to hellow.txt

Solution
docker container run -it alpine /bin/ash
echo "hello world" > hello.txt

list all docker containers

Solution
docker container ls
docker container ls -a

Start docker container from previous step

Solution
docker container start <container ID>

Connect to docker container used in previous step using docker exec

Solution
docker container exec -it <container ID>

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