Table of contents
- Play with docker to practice the docker task
- https://labs.play-with-docker.com/
- How to check whether docker is installed or not
- Let's play with docker images we will perform the following activity.
- How to check docker images available on your machine
- how to delete docker images available on the machine
- How to create a custom container using another container.
- How to enter the container.
Play with docker to practice the docker task
https://labs.play-with-docker.com/
How to check whether docker is installed or not
Let's play with docker images we will perform the following activity.
Firstly create your account on https://hub.docker.com/ and verify your account.
Check all the images available
https://hub.docker.com/search?q=
For example, to use a Python image I don't need to create an image of python, I can use the official image available on https://hub.docker.com/
Let's see how it works I want to use Python images just search for Python images or any other image on the docker hub.
Click on python and you will find a way to pull the image
If your looking for a specific version you can find use specific tag and install that image
If we don't specify the tag it will pull the default image from the docker hub
To search for python on the docker hub, for testing give the command
docker pull python --- This will bring the default image but if you mention using the supported tag the docker pull python:3.12.0b3-bookworm
How to check docker images available on your machine
docker images command will list the images available
how to delete docker images available on the machine
How to create a custom container using another container.
Note:- A container will run until the application inside is running.
docker run -itd --name mehdi'scontainer python sleep 1000
I will explain the above command in my words
docker run is a standard command -itd is to run in the background if not the terminal gets hung and --name I gave a custom name you can give anything and python container as example you can take ubuntu or anything you like and finally sleep 1000 so that container run for few seconds.
How to enter the container.
In the above example, we created a container now we will enter the container with a Python version check and prompt for the Python program to run.
You can view Python version 3.11.4 and print the function to display Python code.