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

Install docker

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

Share

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

Basic requirements for using docker

Kernel version must be above 3.10

Https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

Create a yum source:

[root@localhost ~] # vim / etc/yum.repos.d/docker-ce.repo

[docker-ce]

Name=docker-ce

Baseurl= https://download.docker.com/linux/centos/7/x86_64/stable/

Gpgcheck=0

Enable=1

Execute:

[root@localhost ~] # yum repolist

Time is slow:

Yum-y install docker-ce

Download the latest version of docker by default

Because of the network speed, we can generally take another method to download from our country. Many domestic websites provide docker-ce mirrors, such as Aliyun, NetEyun, and Tsinghua University Mirror Station. Here we download them from Aliyun.

Aliyun download solution:

Kill the previous yum source:

[root@localhost ~] # rm-rf / etc/yum.repos.d/docker-ce.repo

Yum install-y yum-utils device-mapper-persistent-data lvm2

Yum-config-manager-- add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Confirm that there are packages available in the warehouse:

[root@localhost ~] # yum repolist

Cache to improve download speed:

[root@localhost ~] # yum makecache

View the available versions of docker:

Yum list docker-ce.x86_64-- showduplicates | sort-r

Here we download the specified version 18.9.0. Note that we did not take the method officially recommended by Aliyun. We downloaded the three components of docker-ce,docker-ce-cli,containerd.io respectively.

[root@localhost] # yum-y install docker-ce-18.09.0-3.el7 docker-ce-cli-18.09.0-3.el7 containerd.io-1.2.0-el7

Enable docker:

[root@localhost ~] # systemctl start docker

Set self-boot:

[root@localhost ~] # systemctl enable docker

Installation of docker completed

View the downloaded version of docker:

[root@localhost] # docker-v

View docker details:

[root@localhost ~] # docker version

Note:

If your linux is minimized, execute one of the following, tab command completion:

If the installation is not minimized, you do not have to execute the following command

[root@localhost ~] # yum-y install bash-completion

The basic concepts of docker:

Image: mirroring

Container: container

Repostry: warehouse

The image is the cornerstone of the container operation, and the container is the instance after the image is run.

Provide docker with an accelerator so that you don't have to access a foreign network at the beginning of the download and use a domestic network.

Using the docker image accelerator, we use Daoyun's accelerator and, of course, other accelerators, such as Aliyun, Tsinghua Mirror Station and so on.

Curl-sSL https://get.daocloud.io/daotools/set_mirror.sh | sh-s http://f1361db2.m.daocloud.io

Run the service in the background:

[root@localhost ~] # systemctl daemon-reload

Restart docker:

[root@localhost ~] # systemctl restart docker

View docker details:

[root@localhost ~] # docker info

Check it out:

[root@localhost ~] # cat / etc/docker/daemon.json

It's full of key-value pairs.

Where does the image repository point to:

{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}"

Download centos7 image: it will be faster.

[root@localhost ~] # docker pull centos:7

View the local image:

[root@localhost ~] # docker images

Download nginx:

[root@localhost ~] # docker pull nginx

Check to make sure there is a nginx image:

[root@localhost ~] # docker images

Run nginx

If you want to run several machines, execute them several times:

[root@localhost] # docker run-itd-p 80 nginx

Access: the port number displayed by IP plus docker ps

For example:

View the services running using docker:

[root@localhost ~] # docker ps

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