Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic operation of Docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what is the basic operation of Docker". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Download the image

Docker pull centos

two。 View local image

Docker images

3. Search for an image

Docker search centos

4. Create a container

[root@mysql01] # docker run-d-name mydocker-it centos / bin/bash

The-t option lets Docker assign a pseudo terminal (pseudo-tty) and bind it to the standard input of the container

-I keeps the standard input of the container open.

-d deamo mode start

-name uses a custom name, equivalent to an alias

5. Close the container

[root@mysql01 ~] # docker stop mydocker

Mydocker

[root@mysql01 ~] # docker stop bfd094233f96 # stop a container (according to container id)

6. Start the container

[root@mysql01 ~] # docker start mydocker

Mydocker

[root@mysql01 ~] # docker start bfd094233f96 # start a container (based on container id)

7. Enter a running container (container id)

[root@mysql01 ~] # docker attach e7e1e47ca7c1db458bf0b34d6d63294534a530b659a6ee6548197dd9eb639f38 (reduced id recorded in ps)

This command is not easy to use. It is recommended to use the following command to enter the container:

[root@localhost docker] # docker inspect-- format "{{.State.Pid}}" mydocker # get container pid

19769

[root@localhost docker] # nsenter-- target 19769-- mount-- uts-- ipc-- net-- pid # enter the container (recommended)

# docker run-d-p 91:80-- name mynginx2 nginx #-p specifies the port mapping, mapping 80 to 91 of host

8 Delete a container

[root@mysql01 ~] # docker rm bfd094233f96 # Delete a container

9. Look at all the active containers

[root@mysql01 ~] # docker ps or docker ps-a (all containers)

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

E7e1e47ca7c1 centos "/ bin/bash" 13 minutes ago Up 4 minutes mydocker

10. Save the container as a mirror

[root@mysql01 ~] # docker commit mydocker myimages

Sha256:deb3c65069c125f2cb258368a8f7c3ecec6add2df29dcfa00d100b772015df85

[root@mysql01 ~] # docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

Myimages latest deb3c65069c1 28 seconds ago 1.78 GB

Docker.io/centos latest 2d194b392dd1 3 weeks ago 195 MB

This is the end of the content of "what is the basic Operation of Docker". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report