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

Basic knowledge of Docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Basic Container knowledge

Container-level virtualization no longer creates a separate kernel for each virtual machine, but isolates six resources on the host kernel through a kernel mechanism (namespaces), and each namespace is a separate container.

Container technology in the field of Linux is implemented by 6 namespaces, chroot and Cgroups at kernel level.

Namespaces

Isolate user space, isolating processes from other processes.

Namesapce system call parameters isolate content kernel version MountCLONE_NEWNW mount point (file system) 2.4.19UTSCLONE_NEWUTS hostname and domain name 2.6.19IPCCLONE_NEWIPC semaphore, message queue and shared memory 2.6.19PIDCLONE_NEWPID process number 2.6.24NetworkCLONE_NEWNET network devices, network stacks, ports and other 2.6.29UserCLONE_NEWUSER users and user groups 3.8

The last one was added to the kernel in version 3.8 of the kernel. So to make good use of container technology, the kernel version needs to be after 3. 8, that is, Centos7.

Control Groups (cgroups)

The isolation mechanism of containerization technology is realized by namespaces, while the resource allocation of containerization is realized by kernel level through CGroups mechanism. It divides system-level resources into multiple groups, and then assigns the amount of resources within each group to specific namespace processes.

Cgroups, resource restrictions, limit the CPU and memory consumed by the process:

Blkio: block device IOcpu: CPUcpuacct: CPU Resource usage report cpuset: CPU Collection on multiprocessor platforms devices: device access freezer: suspend or resume tasks memory: memory usage and reporting perf_event: unified performance testing of tasks in cgroup net_cls: category identifiers of data messages created by tasks in cgroup

CPU is a compressible resource. Memory is a non-compressible resource and must not be allowed to cross the boundary.

Container orchestration tool

The three choreography tools of Docker:

Docker Compose: a tool for assembling multi-container applications that can be deployed in Swarm clusters. Docker Swarm: a container cluster management tool natively provided by the Docker community. Docker Machine: a tool that supports multi-platform installation of Docker, which makes it easy to install Docker in laptops, cloud platforms, and data centers.

Compose is a stand-alone version. Swarm is a cluster management tool.

None of the above may be needed, because the most popular one is the one below.

Kubernetes: a container orchestration engine open source by K8sMagi Google for short.

K8s needs to be used as a separate topic and a tool to learn, here is just the name of the tool.

Docker architecture

The Docker architecture is as follows and consists of three parts.

There are client-side and server-side (DOCKER_HOST) here, so this is an application based on C _ pact S architecture.

Docker daemon

Docker deamon runs as a daemon. So after running, the host becomes a daemon server.

Docker daemon listens for UNIX sockets or network interfaces. By default, only local UNIX sockets are listening.

Images image, which can be downloaded from registries. All images are read-only.

Containers container, which is started based on the image when the container is started.

Docker client

The client is the main way for users to operate Docker. The docker command uses Docker API, and the client can communicate with multiple daemon.

Docker registries

Docker's image repository.

Docker Hub (https://hub.docker.com/), an official image repository, is abroad. It is recommended to use domestic images.

Install docker

Install docker using yum on Centos7.

CentOS official source

The official source of CentOS has docker. Note that the name used here is docker:

Yum info docker loaded plug-in: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.163.com installable package name: docker Architecture: x86 / 64 period: version 2: 1.13.1 release: 96.gitb2f74b2.el7.centos size: 18m Source: extras/7/x86_64 introduction: Automates deployment of containerized applications Address: https://github.com/docker/docker Protocol: ASL 2.0description: Docker is an open-source engine that automates the deployment of any: application as a lightweight Portable, self-sufficient container that will: run virtually anywhere. :: Docker containers can encapsulate any payload, and will run consistently on: and between virtually any server. The same container that a developer builds: and tests on a laptop will run at scale, in production*, on VMs, bare-metal: servers, OpenStack clusters, public instances, or combinations of the above.$

But the version of this is too low, so don't use the CentOS source.

The version of Docker

Now there are two main versions of Docker software:

Docker-CE: community version, this is a free version Docker-EE: enterprise version, this is a paid version

Docker also has an open source version of Moby, which is also inherited from the previous docker project and maintained by the community. Docker-CE is an open source project maintained by Docoker.

Add Docker-CE Feed

Add Ali's mirror source here. This is the community version of Docker-CE:

$wget-P / etc/yum.repos.d/ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Check the version information and notice that the name used here is docker-ce:

$yum info docker-ce loaded plug-in: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com installable package name: docker-ce Architecture: x86 / 64 period: 3 version: 18.09.7 release: 3.el7 size: 19m Source: docker-ce-stable/x86_64 introduction: The open-source Application container engine Web site: https://www.docker.com Protocol: ASL 2.0 description: Docker is is a product for you to build Ship and run any application as a: lightweight container. :: Docker containers are both hardware-agnostic and platform-agnostic. This means: they can run anywhere, from your laptop to the largest cloud compute instance and: everything in between-and they don't require you to use a particular: language, framework or packaging system. That makes them great building blocks: for deploying and scaling web apps, databases, and backend services without: depending on a particular stack or provider.$ pay attention to version compatibility

The latest version information shown above is 18.09.7, and since docker is generally used with container orchestration tools, k8s is now the most popular. K8s does not necessarily support the latest version, so if you want to install that version, you have to confirm the dependencies of the version.

To query the dependency of K8s on the docker version, you can go to Github's K8s project, project address:

Https://github.com/kubernetes/kubernetes

Query the version of CHANGELOG, such as the file CHANGELOG-1.15.md. There are a lot of files, so search for "Docker version" directly:

The list of validated docker versions remains unchanged.

The current list is 1.13.1, 17.03, 17.06, 17.09, 18.06, 18.09. (# 72823, # 72831)

Install the specified version of docker

Install a version that is not the latest version of 18.06 here.

Query available versions:

$yum list docker-ce--showduplicates | expand loaded plug-in: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com installable package docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.1.ce-1.el7.centos Docker-ce-stabledocker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stabledocker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.09.1.ce-1.el7.centos Docker-ce-stabledocker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stabledocker-ce.x86 _ 64 18.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.2. Ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stabledocker-ce.x86_64 3Rank 18.09.0-3.el7 docker-ce-stabledocker-ce.x86_64 3Rank 18.09.1-3.el7 Docker-ce-stabledocker-ce.x86_64 3Rd 18.09.2-3.el7 docker-ce-stabledocker-ce.x86_64 3RV 18.09.3-3.el7 docker-ce-stabledocker-ce.x86_64 3RO 18.09.4-3.el7 docker-ce-stabledocker -ce.x86_64 3VR 18.09.5-3.el7 docker-ce-stabledocker-ce.x86_64 3VR 18.09.6-3.el7 docker-ce-stabledocker-ce.x86_64 3VR 18.09.7-3.el7 docker-ce-stable$

The effect of the expand command is to make the output a little more compact, replacing tabs with spaces.

Install the specified version:

Yum install docker-ce-18.06.0.ce-3.el7

Start and verify

Start the service, boot, and view the version information:

$systemctl start docker.service$ systemctl enable docker.serviceCreated symlink from / etc/systemd/system/multi-user.target.wants/docker.service to / usr/lib/systemd/system/docker.service.$ docker versionClient: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:08:18 2018 OS/Arch: linux/ Amd64 Experimental: falseServer: Engine: Version: 18.06.0-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:10:42 2018 OS/Arch: linux/amd64 Experimental: false$

Here you can see the client and Server versions respectively. Docker is developed in the Goto language, and there is a version that displays Go. In addition, there is the version of the platform linux/amd64. When you use or download other components later, you can choose the corresponding version according to the compatibility issues related to the platform.

Use Mirror Accelerator

The default image repository is abroad, and it is best to use an official image site in China. Here are a few:

Ali Yun Accelerator: https://help.aliyun.com/document_detail/60750.html NetEase Accelerator: http://hub-mirror.c.163.com official China Accelerator: https://registry.docker-cn.com University of Science and Technology of China Mirror: https://docker.mirrors.ustc.edu.cn

Ali Yun's can not be used directly, because you need to register, the effect should be very good.

Although docker-cn is official, the acceleration effect is also very poor. Probably do not understand the national conditions.

Both NetEase and China University of Science and Technology can be used.

Use the configuration file / etc/docker/daemon.json, and create it manually if the directory or file does not exist. Add the following to the configuration file:

{"registry-mirrors": ["http://hub-mirror.c.163.com"," https://registry.docker-cn.com"]}

The configuration here uses the JSON format. If the configuration takes effect, the service needs to be restarted.

Configuration file

Only one configuration item is used above. The complete configuration item information can be viewed in the official documentation:

Https://docs.docker.com/engine/reference/commandline/dockerd/#Daemon-configuration-file

All the configuration items should be here, and you can check them later when you need them.

Docker command

The help information for performing docker printing without any parameters is as follows:

DockerUsage: docker [OPTIONS] COMMANDA self-sufficient runtime for containersOptions:-- config string Location of client config files (default "/ root/.docker")-D,-- debug Enable debug mode-H,-- host list Daemon socket (s) to connect to-l -log-level string Set the logging level ("debug" | "info" | "warn" | "error" | "fatal") (default "info")-- tls Use TLS Implied by-tlsverify-tlscacert string Trust certs signed only by this CA (default "/ root/.docker/ca.pem")-tlscert string Path to TLS certificate file (default "/ root/.docker/cert.pem")-tlskey string Path to TLS key file (default "/ root/.docker/key.pem")-tlsverify Use TLS and verify the remote-v -- version Print version information and quitManagement Commands: config Manage Docker configs container Manage containers image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumesCommands: attach Attach local standard input, output And error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container ) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop Then print their exit codesRun 'docker COMMAND-- help' for more information on a command.$ subcommand

Here are Management Commands and Commands. Docker has many subcommands, and the early docker was Commands-style, each of which was separate. Now that there are more commands, there are many groups for these subcommands to manage, and this is Management Commands. So the two command styles have the same effect. For example, the following two commands are the same:

Docker rundocker container run

It is recommended that you use Management Commands commands as much as possible.

The calling process of Go command

Here is a digression, such a good command-line interface, curious about how to do it.

The golang command line library cobra: https://github.com/spf13/cobra is used.

You can take a look at the analysis of this article: https://www.jianshu.com/p/9900ec52f2c1

It may be noted that the design of Docker is in Client-Server mode, and the docker command we use is distributed to the https://github.com/docker/cli warehouse.

Detailed system information

Previously, I used the docker version command to view the version information, which can be viewed in more detail using the docker info command:

$docker system infoContainers: 0 / / Total number of containers Running: 0 / / number of containers in running state Paused: 0 / / number of containers in paused state Stopped: 0 / / number of containers in stopped state Images: 0 / / number of images Server Version: 18.06.0-ce / / server version Storage Driver: overlay2 / / Storage driver backend Backing Filesystem: xfs Supports D_type: true Native Overlay Diff: trueLogging Driver: json-fileCgroup Driver: cgroupfsPlugins: / / plug-in Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: d64c661f1d51c48782c9cec8fda7604785f93587runc version: 69663f0bd4b60df09991c08812a60108003fa340init version: fec3683Security Options: / / Security options seccomp Profile: defaultKernel Version: 3.10.0-957.el7.x86_64 / / Kernel version Operating System: CentOS Linux 7 (Core) OSType: linuxArchitecture: x86 _ 64CPUs: 1Total Memory: 908.2MiBName: DockerID: HB7V:B35V:AGQR:Z4JM:WLZ3:T53Y:DXAD:R3HE:OIMS:ODXL:QKDB:MQESDocker Root Dir: / var/lib/dockerDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries: 127.0.0.0/8Registry Mirrors: / / Mirror Accelerator http://hub-mirror.c.163.com/ https://registry.docker-cn.com/Live Restore Enabled: false$

For some of the above information, I added a note to the corresponding line in a similar way.

Networ network

View the networks that the container can use:

$docker network lsNETWORK ID NAME DRIVER SCOPE39cd19b7d266 bridge bridge locald086953087bb host host localfa0c7f1fb6ca none null local$

The contents of the container network also need to be expanded separately, and here is just a demonstration of network commands.

Search for an image

You can use the command to search for images: docker search. This command doesn't belong to any Management Commands, so just use it like this:

$docker search nginx

The output of the command is not very good-looking. The following is to use the-- format parameter to output the complete JSON format:

$docker search nginx-- limit 5-- format'{{json.}}'{"Description": "Official build of Nginx.", "IsAutomated": "false", "IsOfficial": "true", "Name": "nginx", "StarCount": "11680"} {"Description": "Automated Nginx reverse proxy for docker con …" , "IsAutomated": "true", "IsOfficial": "false", "Name": "jwilder/nginx-proxy", "StarCount": "1627"} {"Description": "Container running Nginx + PHP-FPM capable of..." , "IsAutomated": "true", "IsOfficial": "false", "Name": "richarvey/nginx-php-fpm", "StarCount": "726"} {"Description": "Bitnami nginx Docker Image", "IsAutomated": "true", "IsOfficial": "false", "Name": "bitnami/nginx", "StarCount": "69"} {"Description": "NGINX Ingress Controller for Kubernetes", "IsAutomated": "false", "IsOfficial": "false", "Name": "nginx/nginx-ingress" "StarCount": "20"}

Here you get not only the contents of all the fields, but also the field names of each field.

Now you can also adjust the-- format parameter to customize the format of the output:

$docker search nginx-- limit 5-- format'{{.Name}}\ t {{.Description}}\ t {{.StarCount}}\ t {{. IsOfficial | printf "% Q"}}\ t {{. IsAutomated | printf "% Q"}} 'nginx Official build of Nginx. 11680 "[OK]" jwilder/nginx-proxy Automated Nginx reverse proxy for docker con... 1627 "" [OK] "richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of … 726 "[OK]" bitnami/nginx Bitnami nginx Docker Image 69 "[OK]" nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 20 "$"

If the default output is too long, it will be staged, such as the Description field. The-- no-trunc parameter can be used to prevent the content from being truncated.

However, the structure of the search does not have detailed tag information, so this command is not very useful. If you want to search for an image, go directly to hub.docker.com.

Docker Hub search for images

Use a browser to access docker hub: https://hub.docker.com/

Enter the name of the image you want to search in the home search box, such as "hello-world". After entering, click the TAGS tab to view different versions of the image.

Other image repositories

In addition to Docker Hub's official image repository, there are other image repositories, such as Quay: https://quay.io/

Image mirroring operation

The first step is to create an image locally, which can be obtained from the image repository.

Pull the image

Pull the image from the image repository:

$docker image pull hello-worldUsing default tag: latestlatest: Pulling from library/hello-world1b930d010525: Pull complete Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20fStatus: Downloaded newer image for hello-world:latest$

If you do not specify tag, the default is latest.

View the downloaded image

The view is ls:

$docker image lsREPOSITORY TAG IMAGE ID CREATED SIZEhello-world latest fce289e99eb9 6 months ago 1.84kB$

The IMAGE ID here is the unique ID of the image. REPOSITORY and TAG can be used when specifying an image, but a local image can be without these two attributes. But there must be an IMAGE ID, and the image can also be specified through IMAGE ID.

The ID shown above is only part of it. You can use the-- no-trunc parameter to see the complete:

$docker image ls-- no-trunc-- format'{{.Repository}}: {{.tag}} {{.ID}} 'hello-world:latest sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e$

When specifying images, it is possible to use either full or partial ID.

Delete a local mirror

If you make a mistake, or if you don't need it, you can delete it. The command is docker image rm, or you can use docker rmi.

Note that this is not docker rm, the container that this command operates on, and the corresponding command is docker container rm.

This is also the reason why it is recommended to use the Management Commands command, which clearly specifies what kind of operation to do. In this way, when you need to operate image, you will not execute a command to container because of misoperation.

Container container operation

Let's take a look at the next help command, and here are all container-related subcommands:

$docker container-- helpUsage: docker container COMMANDManage containersCommands: attach Attach local standard input, output And error streams to a running container commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem exec Run a command in a running container export Export a container's filesystem as a tar archive inspect Display detailed information on one or more containers kill Kill one or more running containers logs Fetch the logs of a container ls List Containers pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container prune Remove all stopped containers rename Rename a container restart Restart one or more containers rm Remove one or more containers run Run a command in a new container start Start one or more stopped containers stats Display a live stream of container (s) resource usage statistics stop Stop one or more running containers top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers wait Block until one or more containers stop Then print their exit codesRun 'docker container COMMAND-- help' for more information on a command.$

The main command description:

Create: create a container. The created container is in stop state. Start is required to launch. Start: start the container. Stop:: stops the container. Kill: forcibly stop the container. Run: launch the container directly after creation. This is more commonly used. Rm: delete the container. Pause: pause the container. Unpause: cancel the pause. Top: view the resource consumption of the container, the top command of type Linux. Ls: display container, similar to Linux's ps command, so you can use docker ps directly. Run command

Execute docker container run-- help to see the format in which the command runs:

Docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]

Commands executed when the container is started

[COMMAND] is optional and specifies the command to run when the container is started.

[ARG...] Are parameters passed like a command.

Docker's container is designed to run a single program. It is a single process, but multiple processes can be run within the container at the same time.

Each mirror has a defined program to run by default. When starting the container based on an image, if no command is specified, the program specified by default in the image is executed.

Of course, you can also manually specify the command to run when the image is started, which is the [COMMAND] parameter above.

Options when starting the container

[OPTIONS] is a bunch of arguments to run commands. Here are a few important ones to say:

-t,-- tty: assign a terminal. If you want to run as an interactive interface, to open shell, you cannot open shell without a terminal. -I,-- interactive: exchange access. It is usually-it, and the two parameters are used together. -- name string: give the launched container a name. -- network string: specify the connected network when you start the container. Do not specify to use the default, default to join the bridge network. -- rm: once the container is stopped, the container is automatically deleted. -d,-- detach: let the container run directly in the background. Otherwise it will occupy the terminal all the time. Busybox

Here to actually run a container and perform various operations.

The image of busybox is very small, and it is not a system distribution. The original purpose of this tool was to create a bootable GNU/Linux system on a floppy disk, which can be used as an installation disk and a first aid disk. It is a software that integrates more than 300 of the most commonly used Linux commands and tools.

Direct start

Directly start the image as a container:

$docker container run-name bx0 busybox$ docker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES$

The container is not visible to ls at this time, but the container is not deleted but is in a stopped state. By default, only containers with running status are displayed. You need to add the-a parameter here:

$docker container ls-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES3a9b8eb31e01 busybox "sh" 7 minutes ago Exited (0) 7 minutes ago bx0 $

Notice here the value of the COMMAND field, which is the command that runs when the container starts. The container is not specified when it is started, and here is the default command.

There is obviously something wrong with starting the container this time. Delete the container first, and then move on:

$docker container rm bx0

Start and open the terminal

Add the-it parameter to this startup, and assign a shell terminal:

$docker run-- name bx1-it busybox/ # lsbin dev etc home proc root sys tmp usr var/ # lsbin

The last command ls bin can see a lot of commands. These commands are supported by busybox.

Now that it is an interactive interface for shell, you can run the command directly. First, take a look at the ps command:

/ # psPID USER TIME COMMAND 1 root 0:00 sh 10 root 0:00 ps/ #

You can see that the PID of the sh command is 1. The process with PID 1 is init

When the Docker container starts, by default, the first process in the container, that is, the program of pid=1, is used as the basis for whether the docker container is running. If the pid=1 process of the docker container dies, then the docker container will exit directly.

If you exit shell at this point, the container will be closed. When you start the container for the first time, you don't open the terminal, you start a sh command, and then you exit the terminal. So the container is stopped after startup.

/ # exit$ docker container ls-a-- format'{{.Names}}: {{.status}} 'bx1: Exited (126) 4 minutes ago$

Start the container again

The container has been created, so start is fine this time:

$docker container start bx1bx1 $docker container ls-a-- format'{{.names}}: {{.status}} 'bx1: Up 2 seconds$

But now there is no access to the terminal.

You can enter the terminal again with the attach command:

$docker container attach bx1/ # psPID USER TIME COMMAND 1 root 0:00 sh 6 root 0:00 ps/ #

You can also add the-ai parameter directly to start, and the effect is the same:

/ # exit$ docker container start bx1-ai/ #

Exec command

Finally, there is another way to send commands to the container directly on the host machine without entering the host machine, and get the result of the command on the host machine:

$docker container start bx1bx1 $docker container exec bx1 psPID USER TIME COMMAND 1 root 0:00 sh 6 root 0:00 ps$ Summary

Here is a diagram that describes the common commands of the container and the transition of the container state:

There is an OOM (Out Of Memory) in the picture that is out of memory and is using too much memory. The container in the OOM state will be dropped by kill to ensure the sustainable operation of the system. After the OOM is kill, it depends on whether the container mechanism will restart automatically, otherwise it will enter the stopped state.

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