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 on Linux system

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to install docker Linux system, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

Introduction to docker: 1. Mirror image

The docker image is a special file system that provides the resources needed for the container to run. Students who have come into contact with dockerfile should know that when we build an image, we will choose a basic image (don't worry about it below), which means that an docker image is built layer by layer, and an image is often composed of multi-tier file systems.

two。 Container

The mirror is static, and when it runs, it becomes a container. The container is equivalent to a complete operating system, it can have its own file system, its own network configuration. If we use a mysql container to store data, the data will be stored in the storage layer of the current container. The life cycle of the storage layer is the same as that of the container. When the container dies, the storage layer is no longer there, so when we use this kind of container that needs to store data, we often need to specify the data volume Volume (the file directory where a host is mounted), so that even if the container is deleted, the data will not disappear.

3. Warehouse

As the name implies, the docker repository is the place where images are stored. You can upload or download images to the repository. This is relatively simple, there is nothing to say.

Debian/Ubuntu user installation steps the following are modified according to the official documentation.

The old version of Docker may be called docker,docker-engine or http://docker.io. If you have installed docker in the past, delete it first:

Sudo apt-get remove docker docker-engine docker.io first installs dependencies:

Sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common the following content varies depending on your distribution. The distribution you use: Debian Ubuntu

Trust the GPG public key of Docker:

Curl-fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add-for computers with amd64 architecture, add a software repository (in this part, change the address of the official docker repository to the address of the open source software mirror station of Tsinghua University to improve the download speed):

Sudo add-apt-repository\ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu\ $(lsb_release-cs)\ stable" if you have a raspberry pie or other ARM architecture computer, run:

Echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu\ $(lsb_release-cs) stable" |\ sudo tee / etc/apt/sources.list.d/docker.list last installation

Sudo apt-get update sudo apt-get install docker-ceFedora/CentOS/RHEL user installation steps the following are modified according to the official documentation.

If you have installed docker before, please delete it first

Sudo yum remove docker docker-common docker-selinux docker-engine installs some dependencies

Sudo yum install-y yum-utils device-mapper-persistent-data lvm2 downloads the repo file: CentOS/RHEL Fedora based on your distribution

Wget-O / etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo replaces the software repository address with TUNA:

Sudo sed-I's download download.docker.compose mirrors.tuna.tsinghua.edu.cnCompact final installation of dockercopyright CEO'/ etc/yum.repos.d/docker-ce.repo:

The next steps in sudo yum makecache fast sudo yum install docker-ceDocker installation use non-root users to manage docker. By default, docker can only be run under root privileges, and non-root users need to use sudo to run. The latest version of Docker implements the function of non-root users to operate docker by adding docker user groups. It is important to note that the docker user group is essentially the same as the root user, so its impact on system security is the same. To use non-root users to manage docker.

First create the docker user group:

Sudo groupadd docker then adds the current user to the docker user group:

After sudo usermod-aG docker $USER logs out the current user and logs back in (or restarts the computer), the user can be added to the docker user group. On linux systems, you can also quickly activate the docker user group with the following command.

To determine whether the above operation is effective, newgrp docker can run the following command on the command line, which downloads the hello-world image from the docker official and runs it:

Docker run hello-world if you run the docker command line using sudo before adding the current user to the docker user group, you may be prompted with the following error.

WARNING: Error loading config file: / home/user/.docker/config.json-stat / home/user/.docker/config.json: permission denied this error tells you that the permissions created by your ~ / .docker/ folder are incorrect. This problem can be solved by removing the .docker folder under the personal directory and recreating it by the system, or by modifying the owner permissions of the folder.

$sudo chown "$USER": "$USER" / home/ "$USER" / .docker-R $sudo chmod g+rwx "$HOME/.docker"-Boot configuration of RDocker in most modern Linux system distributions, systemd is used to manage self-boot services with the system (upstart is used in Ubuntu14.04 or earlier versions), and the following command is used to enable or disable docker boot self-startup.

Sudo systemctl enable docker / / enable the docker service sudo systemctl disable docker / / disable the docker service Docker automatically configures the boot startup feature through the upstart service, to disable this feature, use the following command:

Echo manual | sudo tee / etc/init/docker.override above are all the contents of the article "how to install docker on a Linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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