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

How to install Docker in Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Linux system how to install Docker, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

To put it simply, a Docker image is an operating system configured with the required environment, and running a docker container on our computer is equivalent to opening a new operating system. The following is to share with you a detailed tutorial on installing Docker on Linux systems.

Introduction to Docker:

Container: a virtualization solution that runs on top of the operating system, or can also be called operating system-level virtualization, depending on the operating system, the container can only run on systems similar to the underlying operating system, docker depends on the Namespace and Cgroups (Control Group) of the Linux kernel, docker can only run on systems similar to linux, window is not available.

Traditional virtual machine: one or more independent machines run virtually on physical machines through the middle tier.

The traditional virtual machine includes not only the complete application and its dependencies, but also the complete operating system, but the container only includes the application and its dependencies, which greatly reduces the resource consumption. The virtual machine simulates the behavior of hardware and consumes a lot of memory and CPU, so if you agree to configure the server, using the container can provide more service capabilities.

But it was not until the advent of docker that containers were noticed, mainly because of the complexity of containers, which depended on many features of the linux kernel and was not easy to install and automate, and it was not until docker changed that.

Docker: automatically deploy the application to the container, written in the GE language. In particular, in the container execution environment, an application deployment engine is added. The goal of the engine is to provide a lightweight and fast environment, which can run the developer's environment, deploy conveniently and efficiently from the developer environment to the test environment, and then to the production environment.

one。 Linux system Docker installation method (1) github official script installation https://github.com/docker/docker-install click to see the documentation. Installation commands:

Curl-fsSL https://get.docker.com-o get-docker.sh sh get-docker.sh (2) set up the yum warehouse to install the Dockeryum:Shell front-end package manager, based on RPM (the package manager of the Linux system, generally comes with it, so you can use the yum command directly), can automatically download the RPM package from the designated server and install it.

1. Install the dependency package sudo yum install-y yum-utils device-mapper-persistent-data lvm22. Set the Ali cloud image source docker-ce Ali cloud image stable version of Docker-ce:

Sudo yum-config-manager-add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo can also be used officially: https://download.docker.com/linux/centos/docker-ce.repo

3. Update the yum cache sudo yum makecache fast4. Install Docker-CE sudo yum install docker-ce## II. Start Docker

Sudo systemctl start docker can be added to boot: sudo systemctl enable docker

three。 Pull image to dockerhub to download image: https://hub.docker.com/ if the pull is slow (in fact, it is very slow to access dockerhub most of the time), configure the image accelerator:

China mirror image of docker official website-- registry-mirror= https://registry.docker-cn.com

Aliyun alicloud (apply for your own accelerator after registration, or look for it online, many)-- registry-mirror= https://{your_id}.mirror.aliyuncs.com

USTC Image acceleration of Tsinghua University-- registry-mirror= https://docker.mirrors.ustc.edu.cn

(1) modify registry-mirrors sudo mkdir-p / etc/docker sudo tee / etc/docker/daemon.json (2) restart sudo systemctl daemon-reload sudo systemctl restart docker (3) pull some commands: # download image: docker pull, for example: docker pull redis docker start redis: docker run-- name dxlcloud-redis\-- restart=always\-v / datadev/redis:/usr/local/etc/redis\-p 63796379\-- D redis-requirepass "root" / / requirepass means set password # View downloaded image docker images # Delete container docker rm # View container log docker logs-f # View running container docker ps # View all containers Including those that have stopped. Docker ps-a # Delete all containers docker rm $(docker ps-a-Q) # stop, start, Kill specified container docker start # Startup container docker stop # Startup container docker kill # Kill container # Host commands to copy files in docker container id: container path Host path # docker Container commands docker cp Host path Container id: container path # docker View Container Startup Log Command docker logs- F-- tail 1000 container id # enter docker container command docker exec-it container id bash (4) other commonly used downloads and launch MySQL: # download: docker pull mysql:5.7 # start: docker run-d\-restart=always\-name=mysql\-v / datadev/mysql:/var/lib/mysql\ / /-v: the first represents the directory hanging out: the latter represents the volume The directory inside the device-v / datadev/my.cnf:/etc/mysql/my.cnf\-p 3306 MongoDB 3306\-e MYSQL_ROOT_PASSWORD=xxxxx mysql:5.7 download and launch (highlight): # 1. Download: docker pull mongo # 2. Start: docker run-d\-p 27017 MONGO_INITDB_ROOT_USERNAME=root 27017\-- name dxl-mongodb\-e MONGO_INITDB_ROOT_USERNAME=root\-e MONGO_INITDB_ROOT_PASSWORD=root mongo # 3. Check out CONTAINER ID docker ps # 4. Enter the docker container docker exec-it [your CONTAINER ID] mongo # 5. After entering, use admin use admin # 6. Enter the account password you just set to connect to the database: db.auth ("root", "root") # 7. After the connection is successful, you can use mongo commands such as: show dbs show collections db.system.users.find () # 8. Leave exit or ctrl+c IV. Uninstall Docker1. Use yum package management: sudo yum remove docker-ce2. Delete the docker installation directory (deleting the docker root directory is a dangerous operation, which will delete docker containers, images and data, please be careful): docker info | grep "Docker Root Dir" / / check the installation directory sudo rm-rf / var/lib/docker # does the default installation directory help you to read the above contents? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Development

Wechat

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

12
Report