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

Installation and configuration of docker and use of common commands

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

Share

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

Download address:

Https://download.docker.com/linux/static/stable/x86_64/

Overview of docker

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable container, then publish them to any popular Linux or Windows machine, or virtualize them. Containers are completely sandboxed and do not have any interface to each other. Each container contains its own application. It can be an application, a set of services, or even an operating system.

The difference between docker and virtual machine

Characteristic docker container virtual machine boot speed seconds minute computing power consumption almost no loss 50% performance close to native weaker than system support (stand-alone) thousands or dozens of isolated resource limits completely isolated

Traditional virtual machines require additional hypervisors and virtual machine operating system layers, while docker containers are virtualized directly above the operational level.

Core concepts of docker

1. Mirror image

The image of docker is the basis for creating a container, similar to a snapshot of a virtual machine, which can be understood as a read-only module for the docker container engine.

two。 Container

The docker container is a running instance created from an image. It can be started, stopped and deleted. Each container created is a platform that is isolated from each other, invisible to each other, and ensures security.

3. Warehouse

Docker repository is a place where images are stored centrally. After creating your own image, you can use push command to upload it to public or private warehouse, so that when you want to use the image on another machine next time, you can pull it down from the warehouse.

Installation of docker

1. Install docker

There are two ways to install docker: one is to use curl to obtain docker's installation script for installation, and the other is to install using the yum repository.

# We are installing using the yum repository

Start the dockers container using systemctl start docker

You can view the daocker version and information through docker version

Docker mirroring operation

1. Search for an image

Before using download images, you can use the docker search command to search for shared images in the remote official repository.

Command format: docker search keyword

The returned information includes image name (NAME), description (DESCRIPTIOM), star (STARS), whether it is officially created (OFFICIAL), and whether it is actively created (AUTOMATED).

two。 Get the image

Use the docker pull command to download the image on the Internet for local use.

Command format: docker pull image name

3. View image information

You can use the docker images command to view mirror information

Docker images repository name, or you can use docker images to view all

4. Rename

Use dockers tag name: tag name: label # is followed by the new name to change to.

For example, if you change docker:dhcp to dhcp:dhcp, do the following

Docker tag docker:dhcp dhcp:dhcp

5. Delete Mirror

Delete using the docker rmi command

For example, delete dhcp:dhcp

6. Save image and load image

Export using the docker save-o command

For example, save the local dhcp:dhcp as a file dhcp

Use dockers load

< 镜像名(打全路径) 载入镜像 例如把dhcp载入 7.上传镜像 使用docker push命令 例如把dhcp上传到私有仓库 docker容器操作 docker的创建就是将镜像加载到容器的过程。docker的容量十分轻量级。用户可以随时创建或者删除。新创建的容器,默认将处于停止状态,不运行任何程序,需要在其中发起一个进程来启动容器,这个进程就是该容器的唯一进程,所以当该进程结束的时候容器也会完全停止,停止的容器可以重新启动并保留原来的修改。 容器创建与启动 使用docker create 选项 镜像运行的程序 -i表示让容器的输入保持打开,-t表示让docker分配一个伪终端。 使用docker ps命令查看所以运行的容器,添加-a选项可以列出系统最后一次启动的容器 启动容器 使用docker start 容器的ID #使用dockers ps -a 可以查看ID 终止容器 使用dockers stop 容器ID 进入容器 docker exec -it 容器ID 容器导出与导入 导入:!!!! 使用docker export 容器ID>

File name

For example, import 60ff4594cc73 into a dhcp file

Export:!

Use cat file name | name of the image to be generated by docker import: label

Deletion of containers

Use the dacker rm command to delete a container

For example, delete the container whose ID number is 60ff4594cc73

If you delete a running container, first use the docker stop container ID to close the container. You can also use the-f option to force the deletion.

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: 291

*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