linux如何安装docker

linux如何安装docker我使用的操作系统是:Linux(阿里云操作系统AliyunLinux,CentOS)安装前的准备工作确认操作系统内核版本是否高于3.10(目前大家使用的较新的发行版都可以满足)[root@aliecs ~]# uname

我使用的操作系统是:Linux(阿里云操作系统AliyunLinux,CentOS)

安装前的准备工作

确认操作系统内核版本是否高于3.10(目前大家使用的较新的发行版都可以满足)

[root@aliecs ~]# uname -r
3.10.0-693.2.2.el7.x86_64

使用官方安装脚本自动安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

脚本会从阿里云的镜像服务器下载安装文件(我用的是阿里云的ECS云服务器,下载速度非常快)

也可以通过DaoCloud国内服务器提供的安装脚本安装

curl -sSL https://get.daocloud.io/docker | sh

安装过程如下:

[root@aliecs docker]# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Executing docker install script, commit: 4f282167c425347a931ccfd95cc91fab041d414f
+ sh -c 'yum install -y -q yum-utils' + sh -c 'yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
packages-microsoft-com-mssql-server-2019 | 3.0 kB 00:00:00
packages-microsoft-com-prod | 3.0 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/9): docker-ce-stable/7/x86_64/filelists_db | 36 kB 00:00:00
(2/9): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(3/9): docker-ce-stable/7/x86_64/primary_db | 87 kB 00:00:00
(4/9): docker-ce-stable/7/x86_64/other_db | 127 kB 00:00:00
(5/9): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(6/9): epel/x86_64/prestodelta | 911 B 00:00:00
(7/9): epel/x86_64/filelists_db | 12 MB 00:00:00
(8/9): epel/x86_64/other_db | 3.4 MB 00:00:00
(9/9): epel/x86_64/primary_db | 7.0 MB 00:00:00
Metadata Cache Created
+ sh -c 'yum install -y -q docker-ce docker-ce-cli containerd.io docker-scan-plugin docker-compose-plugin docker-ce-rootless-extras'
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.6.9-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.6.9-3.1.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
setsebool: SELinux is disabled.
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: https://docs.docker.com/go/attack-surface/
================================================================================

启动docker服务

service docker start

设置开机自启动docker服务(可选)

systemctl enable docker

成功后显示如下内容

[root@aliecs ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

运行hello world

docker run ubuntu:15.10 /bin/echo "Hello world"

docker run:是Docker命令,它会在容器内运行一个应用程序,这个应用程序的功能仅仅是打印Hello world。

ubuntu:15.10:是指定要运行的镜像,Docker 首先从本地主机上查找镜像是否存在,如果不存在,Docker 就会从镜像仓库 Docker Hub 下载公共镜像。

[root@aliecs docker]# docker run ubuntu:15.10 /bin/echo "Hello world"
Unable to find image 'ubuntu:15.10' locally
15.10: Pulling from library/ubuntu
7dcf5a444392: Pull complete
759aa75f3cee: Pull complete
3fa871dc8a2b: Pull complete
224c42ae46e7: Pull complete
Digest: sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3
Status: Downloaded newer image for ubuntu:15.10
Hello world

安装 Docker Compose

Docker Compose 存放在Git Hub,不太稳定。你可以也通过执行下面的命令,高速安装Docker Compose。

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.12.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

目前2.12.2是最新版,也可以修改这个数字为希望安装的版本号。

经测试,文件不大,下载速度特别快(大概用了3秒)

[root@aliecs ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/v2.12.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 425 100 425 0 0 454 0 --:--:-- --:--:-- --:--:-- 453
100 42.8M 100 42.8M 0 0 11.0M 0 0:00:03 0:00:03 --:--:-- 11.7M

【我是物联网人,每天记录物联网相关技术的点滴随笔,想了解的朋友请加关注,点赞,转发,感谢您的支持】

2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/15575.html

(0)
上一篇 2024年 5月 19日
下一篇 2024年 5月 19日

相关推荐

关注微信