image

In this lab, we will create docker container by pulling an existing docker image and interact with it


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.

imageClick on start imageIt will start a 4 hr session image
click on + ADD NEW INSTANCE

image

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

Use below command to complete this task

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

Task: check docker images available on local system

Solution
 docker images

Task: check all docker images available on local system

Solution
 docker images -a

Task: check all docker images for ubuntu available on local system

Solution
docker images ubuntu

Task: check all docker images with docker image command

Solution
docker image ls

Task: Run a docker container with image alpine

and run command ls -la inside it

Solution
docker container run alpine ls -l

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

Task: Run a docker container with image alpine and connect to its shell

Solution
docker container run alpine /bin/sh

Task: Run a docker container with image alpine and connect to its shell

write to “hello world” to hello.txt

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

Task: list all running docker containers on local system

Solution
docker container ls
docker container ls -a

Task: Start docker container from previous step

Solution
docker container start <container ID>

TasK: Connect to docker container used in previous step using docker exec

Solution
docker container exec -it <container ID>

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.