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 quickly install docker under Linux

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

Share

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

This article mainly introduces "how to install docker quickly under Linux". In daily operation, I believe many people have doubts about how to install docker quickly under Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to install docker quickly under Linux". Next, please follow the editor to study!

1. Install the dependency package sudo yum install-y yum-utils device-mapper-persistent-data lvm22. Set Ali Cloud Mirror Source

Because the official image source address of docker is foreign by default, and the speed is very slow, the data source is set to the image of Ali Cloud. Of course, there are other domestic mirror sources, and I will not introduce them one by one here.

Sudo yum-config-manager-- add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo3. Install Docker-CE

Docker CE (Community Edition) Community Free Edition, which belongs to the docker engine.

Sudo yum install docker-ce4. Start Docker-CE

Add start Docker service

Sudo systemctl enable dockersudo systemctl start docker

5. Set up user groups for Docker

The communication between the docker command and the Docker engine is through UnixSocket, but users who have access to UnixSocket can only be accessed by users of the root and docker user groups, so we need to establish a docker user group and add users who need to access docker to this user group.

1. Establish a Docker user group

Sudo groupadd docker

two。 Add current user to docker group

Sudo usermod-aG docker $USER

6.GUI management configuration (optional)

Gui management tools can be installed and used if necessary, without mandatory requirements. Portainer

Official address: https://portainer.io/install.html (if the foreign address is not accessible, it is recommended to climb the wall)

Installation commands:

Docker volume create portainer_datadocker run-d-p 9000 9000-v / var/run/docker.sock:/var/run/docker.sock-v portainer_data:/data portainer/portainer

Then access it through your own IP+9000 port

Below you can see your own container, image, and so on.

Introduction to the basic concepts of 7.Docker

Mirror (Image)

It holds the application and the dependent environment needed, such as running runtime and webapp.

Why do I need multiple mirrors? When developing, building, and running containerized applications, we usually have different priorities. By providing different mirrors for these separate tasks

Container (Container)

An instance of the mirror. A container represents a running application, process, or service. It consists of a Docker image, an execution environment, and a standard instruction set. When I need to extend the service, I actually mirror what the mirror runs in the container. Can be seen as a completely isolated box.

A container mirror instance represents a separate process.

Hub

On the platform where images are stored remotely, there are already many created images on hub, such as redis mongodb.

Warehouse (repository)

The place where the warehouse holds the image.

After the image is built, it can be run directly on the current host, but if you need to use the image on other servers, you need a service that centrally stores and distributes the images. The warehouse is such a service.

8.Docker common commands

Docker ps-View all containers that are currently running-a display includes containers that have stopped

Docker pull-pull image

Docker rmi-after deleting an image, it can be matched directly based on the image name or the first letter of tag.

Docker start container_id-Open the container (here it can be the container id or name)

Docker stop container_id-stop the container (here it can be the container id or name)

Docker rm-Delete containers (only stopped containers can be deleted)

Docker build-create a mirror using Dockerfile

Docker exec-execute commands in the container, for example: docker exec-it container_id (container name or id) / bin/bash (command or tool to be executed by bin/bash)

Docker logs-View the container log, for example: docker logs-f-t-tail 10 container_id (container name or id)

Run the container

Docker run-it-rm-p 8000 rm 80-name aspnet_sample microsoft/dotnet__

-name container name, followed by the image path or name

-delete the container after the rm is run

-p Port Mapping 8000 the port running in the external port 80 mirror maps 8000 to the 80 in the mirror.

-the contents of the it output container command line, that is, the container's own program output, is a bit like running in the foreground on the console.

-d runs in the background as opposed to it.

At this point, the study on "how to quickly install docker under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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