首页 > 系统相关 >CentOS7.9 全自动装docker:v1

CentOS7.9 全自动装docker:v1

时间:2023-01-26 20:56:37浏览次数:46  
标签:00 x86 v1 ce CentOS7.9 64 docker el7

命令(直接复制执行即可):

service firewalld stop
systemctl disable firewalld.service
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
yum remove docker docker-client docker-client-latest docker-common docker-latest-logrotate docker-logrotate docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
echo "nameserver  8.8.8.8">/etc/resolv.conf
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install wget net-tools vim -y
yum search docker-ce
yum install -y docker-ce-19.03.6 docker-ce-cli-19.03.6 containerd.io
service docker start
systemctl enable docker.service
sed -i '14s/^/# /' /usr/lib/systemd/system/docker.service
sed -i '14a ExecStart=\/usr\/bin\/dockerd -H tcp:\/\/0.0.0.0:2375 -H unix:\/\/var\/run\/docker.sock -H fd:\/\/  --containerd=\/run\/containerd\/containerd\.sock' \/usr\/lib\/systemd\/system\/docker\.service
systemctl daemon-reload
systemctl restart docker
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://plqjafsr.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
docker run hello-world

 

 

 


====================================================================================================================================================================
实践:

[root@localhost ~]# service firewalld stop
-engine

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

echo "nameserver  8.8.8.8">/etc/resolv.conf
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum install wget net-tools vim -y
yum search docker-ce
yum install -y docker-ce-19.03.6 docker-ce-cli-19.03.6 containerd.io
service docker start
systemctl enable docker.service

sed -i '14s/^/# /' /usr/lib/systemd/system/docker.service
sed -i '14a ExecStart=\/usr\/bin\/dockerd -H tcp:\/\/0.0.0.0:2375 -H unix:\/\/var\/run\/docker.sock -H fd:\/\/  --containerd=\/run\/containerd\/containerd\.sock' \/usr\/lib\/systemd\/system\/docker\.service

systemctl daemon-reload
systemctl restart docker
docker info

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
 Redirecting to /bin/systemctl stop firewalld.service
 "registry-mirrors": ["https://plqjafsr.mirror.aliyuncs.com"]
}
EOF

systemctl daemon-reload
systemctl restart docker

docker run hello-world


[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# yum remove docker docker-client docker-client-latest docker-common docker-latest-logrotate docker-logrotate docker-engine
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
[root@localhost ~]#
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
[root@localhost ~]#
[root@localhost ~]# echo "nameserver  8.8.8.8">/etc/resolv.conf
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]#
[root@localhost ~]# yum install wget net-tools vim -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
base                                                                                                                                                | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                    | 3.5 kB  00:00:00     
extras                                                                                                                                              | 2.9 kB  00:00:00     
updates                                                                                                                                             | 2.9 kB  00:00:00     
(1/6): extras/7/x86_64/primary_db                                                                                                                   | 249 kB  00:00:00     
(2/6): updates/7/x86_64/primary_db                                                                                                                  |  19 MB  00:00:00     
(3/6): docker-ce-stable/7/x86_64/updateinfo                                                                                                         |   55 B  00:00:02     
(4/6): base/7/x86_64/primary_db                                                                                                                     | 6.1 MB  00:00:02     
(5/6): docker-ce-stable/7/x86_64/primary_db                                                                                                         |  93 kB  00:00:02     
(6/6): base/7/x86_64/group_gz                                                                                                                       | 153 kB  00:00:10     
Package wget-1.14-18.el7_6.1.x86_64 already installed and latest version
Package net-tools-2.0-0.25.20131004git.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.629-7.el7 will be updated
---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be an update
--> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Running transaction check
---> Package vim-common.x86_64 2:7.4.629-7.el7 will be updated
---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                   Arch                                Version                                          Repository                            Size
===========================================================================================================================================================================
Updating:
 vim-enhanced                              x86_64                              2:7.4.629-8.el7_9                                updates                              1.1 M
Updating for dependencies:
 vim-common                                x86_64                              2:7.4.629-8.el7_9                                updates                              5.9 M

Transaction Summary
===========================================================================================================================================================================
Upgrade  1 Package (+1 Dependent package)

Total download size: 7.0 M
Downloading packages:
No Presto metadata available for updates
warning: /var/cache/yum/x86_64/7/updates/packages/vim-enhanced-7.4.629-8.el7_9.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for vim-enhanced-7.4.629-8.el7_9.x86_64.rpm is not installed
(1/2): vim-enhanced-7.4.629-8.el7_9.x86_64.rpm                                                                                                      | 1.1 MB  00:00:00     
(2/2): vim-common-7.4.629-8.el7_9.x86_64.rpm                                                                                                        | 5.9 MB  00:00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                       14 MB/s | 7.0 MB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-9.2009.0.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 2:vim-common-7.4.629-8.el7_9.x86_64                                                                                                                     1/4
  Updating   : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                                                                                                                   2/4
  Cleanup    : 2:vim-enhanced-7.4.629-7.el7.x86_64                                                                                                                     3/4
  Cleanup    : 2:vim-common-7.4.629-7.el7.x86_64                                                                                                                       4/4
  Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                                                                                                                   1/4
  Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                                                                                                                     2/4
  Verifying  : 2:vim-common-7.4.629-7.el7.x86_64                                                                                                                       3/4
  Verifying  : 2:vim-enhanced-7.4.629-7.el7.x86_64                                                                                                                     4/4

Updated:
  vim-enhanced.x86_64 2:7.4.629-8.el7_9                                                                                                                                    

Dependency Updated:
  vim-common.x86_64 2:7.4.629-8.el7_9                                                                                                                                      

Complete!
[root@localhost ~]# yum search docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
========================================================================= N/S matched: docker-ce ==========================================================================
docker-ce.x86_64 : The open-source application container engine
docker-ce-cli.x86_64 : The open-source application container engine
docker-ce-rootless-extras.x86_64 : Rootless support for Docker
docker-ce-selinux.noarch : SELinux Policies for the open-source application container engine

  Name and summary matches only, use "search all" for everything.
[root@localhost ~]# yum install -y docker-ce-19.03.6 docker-ce-cli-19.03.6 containerd.io
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.15-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.15-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:19.03.6-3.el7 will be installed
---> Package docker-ce-cli.x86_64 1:19.03.6-3.el7 will be installed
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                   Arch                           Version                                           Repository                                Size
===========================================================================================================================================================================
Installing:
 containerd.io                             x86_64                         1.6.15-3.1.el7                                    docker-ce-stable                          33 M
 docker-ce                                 x86_64                         3:19.03.6-3.el7                                   docker-ce-stable                          24 M
 docker-ce-cli                             x86_64                         1:19.03.6-3.el7                                   docker-ce-stable                          40 M
Installing for dependencies:
 container-selinux                         noarch                         2:2.119.2-1.911c772.el7_8                         extras                                    40 k

Transaction Summary
===========================================================================================================================================================================
Install  3 Packages (+1 Dependent package)

Total download size: 97 M
Installed size: 385 M
Downloading packages:
(1/4): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                         |  40 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.6-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY  52 MB  00:00:05 ETA
Public key for docker-ce-19.03.6-3.el7.x86_64.rpm is not installed
(2/4): docker-ce-19.03.6-3.el7.x86_64.rpm                                                                                                           |  24 MB  00:00:05     
(3/4): containerd.io-1.6.15-3.1.el7.x86_64.rpm                                                                                                      |  33 MB  00:00:06     
(4/4): docker-ce-cli-19.03.6-3.el7.x86_64.rpm                                                                                                       |  40 MB  00:00:04     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                      9.6 MB/s |  97 MB  00:00:10     
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <[email protected]>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                      1/4
  Installing : containerd.io-1.6.15-3.1.el7.x86_64                                                                                                                     2/4
  Installing : 1:docker-ce-cli-19.03.6-3.el7.x86_64                                                                                                                    3/4
  Installing : 3:docker-ce-19.03.6-3.el7.x86_64                                                                                                                        4/4
  Verifying  : 3:docker-ce-19.03.6-3.el7.x86_64                                                                                                                        1/4
  Verifying  : containerd.io-1.6.15-3.1.el7.x86_64                                                                                                                     2/4
  Verifying  : 1:docker-ce-cli-19.03.6-3.el7.x86_64                                                                                                                    3/4
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                      4/4

Installed:
  containerd.io.x86_64 0:1.6.15-3.1.el7                     docker-ce.x86_64 3:19.03.6-3.el7                     docker-ce-cli.x86_64 1:19.03.6-3.el7                    

Dependency Installed:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8                                                                                                                       

Complete!
[root@localhost ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]#
[root@localhost ~]# sed -i '14s/^/# /' /usr/lib/systemd/system/docker.service
[root@localhost ~]# sed -i '14a ExecStart=\/usr\/bin\/dockerd -H tcp:\/\/0.0.0.0:2375 -H unix:\/\/var\/run\/docker.sock -H fd:\/\/  --containerd=\/run\/containerd\/containerd\.sock' \/usr\/lib\/systemd\/system\/docker\.service
[root@localhost ~]#
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.6
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 5b842e528e99d4d4c1686467debf2bd4b88ecd86
 runc version: v1.1.4-0-g5fd4c4d
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1160.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.62GiB
 Name: localhost.localdomain
 ID: BEIM:M3D4:W4NF:T2DR:BLFM:G4GR:FGZM:3JL4:AGCT:GSJ3:HSBL:MYTV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
[root@localhost ~]#
[root@localhost ~]# mkdir -p /etc/docker
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://plqjafsr.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://plqjafsr.mirror.aliyuncs.com"]
}
[root@localhost ~]#
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]#
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@localhost ~]#

标签:00,x86,v1,ce,CentOS7.9,64,docker,el7
From: https://www.cnblogs.com/Dennis510/p/17068189.html

相关文章

  • docker部署netcore项目
    1.部署历史猿友们好,作为初来实习的我,已经遭受社会的“毒打”,所以请容许我在下面环节适当吐槽,3Q!传统部署​ 回顾以往在服务器部署webapi项目(非独立发布),dotnet环境、守......
  • docker迁移目录
     停止docker服务  systemctlstopdocker切换目录 cd/var/lib查看目录 ls移动目录mv /var/lib/docker/app/docker查看目录 ls创建软连接 ln-s/app......
  • docker安装
    Docker基本安装**操作系统版本要求**CentOS7要求系统为64位、系统内核版本为3.10以上。CentOS-6.5或更高的版本的CentOS上,要求系统为64位、系统内核版本......
  • ClickHouse分布式安装-Docker环境
    安装背景本文主要介绍了在Docker环境下如何安装ClickHouse集群的过程,ClickHouse集群采用单分片三副本模式进行部署。服务器:bigdata1、bigdata2、bigdata3zookeeper:需要安装z......
  • 成功解决:npm 版本不支持node.js。【 npm v9.1.2 does not support Node.js v16.6.0.】
    文章目录​​1、出现的问题​​​​2、查看自己的npm和node版本​​​​3、解决方法​​​​3.1寻找对应的版本​​​​3.2升级npm版本​​​​4、再次运行项目,成功​​​......
  • docker 日常命令小笔记
    目录​​常见命令​​​​启动并启动日志​​​​进入容器​​​​dockerfiles​​​​apk命令​​​​编辑网卡centos​​​​重启网卡​​​​查看防火墙的状态​​​​......
  • docker-compose安装minio
    minio:RELEASE.2022-09-07T22-25-02Z创建文件vidocker-compose.yml脚本内容如下:version:'3'services:minio:image:minio/minio:RELEASE.2022-09-07T22-......
  • Docker 基础 - 3
    Web服务器与应用Nginx我的NginxDocker镜像##设置继承自己创建的sshd镜像FROMcaseycui/ubuntu-sshd##维护者LABELmaintainer="CaseyCuicuikaidong@foxmai......
  • Docker
     第一章初识Docker1.1Docker概念Docker是一个开源的应用容器引擎诞生于2013年初,基于Go语言实现,dotCloud公司出品(后改名DockerInc)Docker可以让开发者打包他们的应......
  • 解决docker push镜像到私有仓库时的报错【http: server gave HTTP response to HTTPS
    一:解决dockerpush镜像到私有仓库时的报错【http:servergaveHTTPresponsetoHTTPSclient】......