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 Container in Docker

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is Container in 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!

What is Container?

Create through Image (copy)

Create a container layer (readable and writable) on top of Image layer

Analogy object-oriented: classes and instances

Image is responsible for the storage and distribution of app, and Container is responsible for running app

Docker container ls can enumerate locally running containers

Example docker container ls-a lists all containers, including those that are running or have been completed

There is a COMMAND field such as "/ hello", which represents the CMD in Dockerfile ["/ hello"]

More hello-world/Dockerfile check the configuration in this file

When we run container with docker run xxx (image), the commands in CMD ["/ hello"] are executed by default

The docker run xxx command ends after running. It is not a memory-resident process.

Centos is a more complex image, you can use docker run centos to execute this image, if

There is a version of centos that can be run by docker run centos:7 in a specified version.

The way to run the container interactively:

Docker run-it centos can be resident in memory and will not exit directly after running.

Docker run-help query help for running docker

Docker run-I xxx is interactive-I stands for interactive (interactive)

Docker run-t xxx stands for Allocate a pseudo-TTY

Each container created is actually an extra layer on top of the previous image. Use docker container ls to view the running container, such as hello-world

Docker container ls-a can view all containers that have exited or are running, so how do we delete them?

Commands: docker to see what commands docker has

There are two modules for entering the docker command, one is Management Commands and the other is Commands

Management Commands is a command to manage some objects in docker.

Command: docker container rm (ID of container)

Command: docker container ls-a (all containers where container is running or exited)

Command: docker container ls-aq (list all container ID) and docker container ls-a | awk {'print$1'} are the same

Command: docker rm $(docker container ls-aq) to delete all running container

Command: docker container ls-f "status=exited" lists all container whose status is exited, followed by-Q to list only ID

Command: docker rm $(docker container ls-f "status=exited"-Q) to delete all container with exited status

Command: docker ps-an is the same as docker container ls-a

Command: docker rm (ID for container) and docker container rm (ID for container) have the same effect

Command: docker images and docker image ls have the same effect

Command: docker image rm (ID of image) deletes an image

Command: dokcer rmi (image ID) and docker image rm (ID of imaged) are the same

Run the centos container: docker run-it centos to enter the default centos

You can create or edit a file in centos. Similarly, this centos also has the command yum.

By the way, explain the difference between vi and vim, because centos itself does not have vim installed:

They are all multimode compilers. The difference is that vim is an upgraded version of vi. It is not only compatible with all the instructions of vi, but also has some new features in it.

These advantages of vim are mainly reflected in the following aspects:

Multi-level undo We know that in vi, pressing u can only undo the last command, while in vim it can be undone indefinitely.

Easy-to-use vi can only run in unix, while vim can not only run on multi-operating platforms such as unix,windows,mac.

Syntax highlight vim can use different colors to highlight your code.

Visual operation means that vim can run not only on the terminal, but also on x window, mac os, and windows.

Full compatibility with vi in some cases, you can use vim as a vi.

Vi and vim are both compilers in Linux, except that vim is more advanced and can be regarded as an upgraded version of vi. Vi is suitable for text editing, but vim is more suitable for coding.

Vi has three modes: insert mode, command mode, and low-line mode.

Insert mode: you can enter characters in this mode, press ESC to return to command mode

Command mode: you can move the cursor, delete characters, etc.

Low-line mode: you can save files, exit vi, find, and other functions (low-line mode can also be seen as in command mode)

This is the end of the content of "what is Container in 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

Internet Technology

Wechat

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

12
Report