CodeGym /Courses /Docker SELF /First Docker Run

First Docker Run

Docker SELF
Level 9 , Lesson 4
Available

5.1 Checking Docker Version

After installing Docker on your system, it's super important to make sure all its components are working as they should. The first Docker run involves a couple of steps to verify the installation and do initial setup.

Let's start by checking the Docker version. This step confirms that Docker is installed properly and ensures the command line recognizes Docker commands.

1. Open up your terminal or command line:

  1. On Windows: Open PowerShell or the Command Prompt (CMD).
  2. On macOS: Open the terminal (Terminal.app).
  3. On Linux: Open the terminal.

2. Enter the command to check the version:

Terminal

sudo docker --version

You'll see the installed version of Docker in response. For example:

Terminal

Docker version 20.10.7, build f0df350

5.2 Running a Test Container

The next step is to run a test Docker container. This will let you check if the Docker daemon is working and confirm that containers can be launched on your computer.

1. Running the test "hello-world" container:

Terminal

docker run hello-world

When you run this command, Docker will download the "hello-world" image from Docker Hub and launch it in a container. If the image isn't on your computer, the system will automatically pull it.

2. Expected result: If Docker is working correctly, you'll see the following message:

Terminal

Hello from Docker!
This message shows that your installation appears to be working correctly.
       
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
   (amd64)
3. The Docker daemon created a new container from that image which runs the
   executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
   to your terminal.
       
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
       
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
       
For more examples and ideas, visit:
https://docs.docker.com/get-started/
       

5.3 Checking Docker Daemon Status

Now you need to make sure that the Docker Daemon is running.

On Windows and macOS:

Docker Desktop automatically starts the Docker Daemon. You can check its status. On Windows, you'll find the Docker icon in the system tray (at the bottom of the screen, next to the clock). Click on it to check the status. On macOS, the Docker icon is located in the menu bar at the top of the screen next to the system indicators (Wi-Fi, volume). When working normally, the icon will be active without any warning symbols (like a yellow triangle or a red cross).

On Linux:

Enter the command to check the Docker Daemon status:

Terminal

sudo systemctl status docker

You’ll see the output showing the Docker service status. If Docker is working correctly, the status will be "active (running)".

5.4 Checking Docker Network

Docker uses virtual networks for communication between containers and the outside world. Checking the Docker network confirms that containers can interact through the network.

1. List of existing networks:

Terminal

docker network ls

You will see a list of networks created by Docker by default:

Terminal

NETWORK ID          NAME                DRIVER              SCOPE
8d3d90a1e084        bridge              bridge                 local
9e3bdf739d23        host                   host                   local
a34e1b2f4c07        none                   null                    local

2. Creating and checking a custom network:

Create a new network:

Terminal

docker network create my_test_network

Check that the network was created:

Terminal

docker network ls 

You will see the new network "my_test_network" in the list.

5.5 Checking Docker Volumes

Docker uses volumes for persistent container data storage. Checking Docker volumes confirms the ability to create and manage volumes for storing data.

Useful: a volume is kinda like a virtual hard drive. On a real operating system, it's stored as a regular file.

1. List existing volumes:

Terminal

docker volume ls

You will see a list of existing volumes, if there are any.

2. Create and check a custom volume:

Create a new volume:

Terminal

docker volume create my_test_volume

Check that the volume was created:

Terminal

docker volume ls

You will see the new volume "my_test_volume" in the list.

The first Docker run and installation check are important steps to confirm that all components are set up and working correctly. After verifying the Docker version, running a test container, checking the Docker Daemon status, and also checking Docker networks and volumes, you can be sure that your system is ready to work with containers and deploy applications.

3
Task
Docker SELF, level 9, lesson 4
Locked
Checking Docker version
Checking Docker version
3
Task
Docker SELF, level 9, lesson 4
Locked
Running a test container
Running a test container
3
Task
Docker SELF, level 9, lesson 4
Locked
Checking the state of the Docker Daemon
Checking the state of the Docker Daemon
3
Task
Docker SELF, level 9, lesson 4
Locked
Creating a Custom Network
Creating a Custom Network
1
Опрос
Getting to Know Docker,  9 уровень,  4 лекция
недоступен
Getting to Know Docker
Getting to Know Docker
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION