• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Check Docker Installation Details Part - 3

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Exploring Basic Docker Commands



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Now that we've verified our Docker installation works correctly (Part-2), let's explore some basic Docker commands that will help you manage containers and images.

Running an Interactive Container


Unlike the hello-world container that runs and exits immediately, we can run containers interactively.

1.Let's run an Ubuntu container and interact with its shell:


docker run -it ubuntu bash


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



This command:
• -i keeps STDIN open
• -t allocates a pseudo-TTY (terminal)
• ubuntu is the image name.
• bash is the command to run inside the container.

Once the container starts, you'll be at a bash prompt inside the container. The prompt shows you're logged in as root in the container. The alphanumeric string is the container ID.

2.Try running some Linux commands inside the container:


cat /etc/os-release

This will display information about the Ubuntu version running in the container:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



3.When you're done exploring, exit the container by typing:


exit


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



This will return you to your host terminal.

Container Lifecycle Management


4.Let's explore how to manage the lifecycle of a container. First, we'll start a container in detached mode:


docker run -d --name web nginx


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



This command:
• -d runs the container in detached mode (in the background)
• --name web assigns the name "web" to the container
• nginx is the image to use.

You'll see a long container ID printed on the screen.

5.Now, let's check that the container is running:


docker ps


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


You should see the nginx container running.

6.To stop the container:


docker stop web


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



7.Verify it's stopped:


docker ps


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



8.The container should no longer appear in the list of running containers. To see all containers including stopped ones:


docker ps -a


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


You should the nginx containers in the stopped state.

9.To start the container again and check container status:


docker start web

docker ps


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



10.to remove a container when you no longer need it:


docker rm web


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



11.Error response from daemon: cannot remove container "/web": container is running stop the container before removing. First stop the running container then remove and check:


docker stop web

docker rm web

Command: docker ps -a


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



You should see the web container not available.

Managing Docker Images


Let's explore how to manage Docker images. To list all images:
12.Let’s check the docker images available of your system.


docker images


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


You should see at least the hello-world and nginx images.

13.To remove an image when you no longer need it:


docker rmi hello-world


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container be8b92819418 is using its referenced image 74cc54e27dc4.
Note that you can't remove images that are being used by containers (even stopped ones). You'll need to remove those containers first.

14.Let’s remove the hello-world container then remove hello-world image:


Command:docker ps -a

Command: docker rmi hello-world

Command: docker images


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


You should see the hello-world image not available in the images list.

Docker System Information


To check disk space used by Docker (containers, images, volumes):

15.Let’s check disk space used by docker:


docker system df


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


This will show a summary of disk usage.

16.To get more detailed information:


docker system df -v


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



This will show a breakdown of each image and container and their sizes.

LinkedIn:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


GitHub:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Related Keywords:
How to verify Docker installation on your system,
Checking Docker version and system info via CLI,
Confirming Docker is properly installed on Linux/Mac/Windows,
Commands to check Docker installation status,
Troubleshooting Docker setup issues,

Kamrul Hasan DevOps Engineer,
DevOps tips by Kamrul Hasan,
Kamrul Hasan Docker tutorials,
Learn DevOps with Kamrul Hasan,
Kamrul Hasan automation expert,
Kamrul Hasan cloud and containers,
CI/CD pipelines by Kamrul Hasan,
Kamrul Hasan Kubernetes & Docker,


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу