首页 > 系统相关 >linux安装docker

linux安装docker

时间:2024-07-03 11:57:59浏览次数:1  
标签:daemon ce yum Docker linux docker 安装 el7

以下命令均以root权限执行

卸载docker旧版本

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

安装相关工具类

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

配置阿里云的仓库

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

yum install docker-ce

执行安装docker

yum install docker-ce
 
Installed:
  docker-ce.x86_64 0:18.03.0.ce-1.el7.centos
 
Dependency Installed:
  audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7   container-selinux.noarch 2:2.42-1.gitad8f0f7.el7 libcgroup.x86_64 0
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3   pigz.x86_64 0:2.3.3-1.el7.centos policycoreutils-python.x86_64 0:2.5-17.1.el7     python-IPy.noarch
 
Complete!

启动docker

systemctl start docker

验证docker

docker run hello-world

出现以下内容则表示安装成功

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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:

设置开机自启

chkconfig docker on

升级docker ce

yum -y upgrade

配置国内镜像与存储目录

vim /etc/docker/daemon.json

registry-mirrors 为镜像地址

docker 版本<20 graph 为存储目录 建议不要使用默认的 否则空间会不够用

docker 版本>20 graph已经弃用 需使用 data-root

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://docker.nju.edu.cn",
    "https://dockerproxy.com"
  ],
  "data-root": "/home/docker"
}

重启docker

systemctl daemon-reload
systemctl restart docker

Linux 安装 docker-compose

从狮子大佬gitee中下载resources: 一些静态资源存储666 (gitee.com)

下载好之后 上传到系统 /usr/local/bin 目录 并改名为 docker-compose

授权

chmod +x /usr/local/bin/docker-compose

检查版本

1.27.4

docker-compose -version

2.2.2

docker-compose version

docker 开启端口 2375 供外部程序访问 (不推荐,容易被黑客利用)

重点 : 写在最前面,该方法有漏洞,容易被黑客远程放入挖矿机镜像,开启需做好防范

推荐使用 CA加密端口 或者 使用 SSH 转发端口

推荐使用 CA加密端口 或者 使用 SSH 转发端口

docker服务文件位置 /usr/lib/systemd/system/docker.service

编辑 docker.service

找到Service标签下的ExecStart属性

注释掉原来的 , 添加如下内容

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock --containerd=/run/containerd/containerd.sock

重新加载配置并重启docker服务

systemctl daemon-reload
systemctl restart docker.service

记得关闭防火墙或者在防火墙放行2375端口

systemctl stop firewalld.service

标签:daemon,ce,yum,Docker,linux,docker,安装,el7
From: https://www.cnblogs.com/SXLM/p/18281338

相关文章

  • git简介以及git操作软件下载以及安装教程,git基础指令介绍,持续更新中~
    什么是Git?最近在学一些git的基础指令,仔细地了解了一下git,发现了他的强大功能,分享一下:Git是一个强大的工具,它在软件开发中扮演着至关重要的角色。Git是一个开源的分布式版本控制系统,由LinusTorvalds创建,用于有效、高速地处理从小到大的项目。Git是目前世界上最流行的版本......
  • Linux多进程和多线程(一)-进程的概念和创建
    进程进程的概念进程的特点如下进程和程序的区别LINUX进程管理getpid()getppid()进程的地址空间虚拟地址和物理地址进程状态管理进程相关命令pstoppstreekill进程的创建并发和并行fork()父子进程执行不同的任务创建多个进程进程的退出exit()和_exit()exit()函数......
  • 安装Mingw64
    进入官网:MinGW-w64-for32and64bitWindowsdownload|SourceForge.net点击Files,找到如下所示的这个版本双击即可下载,下载完成后解压在c盘将路径“C:\mingw64\bin”设置为环境变量(选中PATH,点击编译——新建)到此完成安装,在powershell输入命令测......
  • Windows 下安装 Qt 教程
    1.下载安装包进入官网,会出现以下内容:其分别代表着:Name注释snapshots预览版,最新测试中的Qt库和开发工具onlineQt在线安装源official_releases正式发布版,相对稳定的Qt库和开发工具ministro迷你版,针对Android的版本learningQt的文档和示范视......
  • debian 12 基于清华源安装docker
    清华源docker地址:https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/安装docker之前需要添加GPG公钥,主要是用来验证安装文件是否被篡改,先安装工具:curl和gnupg2,两个工具。aptinstallcurlgnupg2下面是清华源GPG地址,下载和添加。curl-fsSLhttps://mirrors.t......
  • Linux:文件系统与日志分析
    一、block与inode1.1、概述文件是存储在硬盘上的,硬盘的最小存储单位叫做“扇区”(sector),每个扇区存储512字节。一般连续八个扇区组成一个"块”(block),一个块是4K大小,是文件存取的最小单位。文件数据包括实际数据与元信息(类似文件属性)。文件数据存储在“块"中,存储文件元......
  • 基于gunicorn+flask+docker模型高并发部署
    为了基于Gunicorn、Flask和Docker构建一个高并发的Web应用部署环境,我们需要进行以下几个步骤:编写Flask应用:创建一个简单的Flask应用。配置Gunicorn:使用Gunicorn来管理多个工作进程,提高并发处理能力。创建Docker镜像:编写Dockerfile来创建一个Docker镜像。编写DockerCompose......
  • WSL2安装cuda
    Windows下的WSL2是适用于Linux的Windows子系统体系结构的一个新版本,它支持适用于Linux的Windows子系统在Windows上运行ELF64Linux二进制文件。它的主要目标是提高文件系统性能,以及添加完全的系统调用兼容性。使用WSL2可以很方便地调试程序,在WSL2中部署cuda环境更......
  • Docker 使用 buildx 构建多种系统架构支持的镜像
    在Docker19.03+版本中可以使用 dockerbuildxbuild 命令使用 BuildKit 构建镜像。该命令支持 --platform 参数可以同时构建支持多种系统架构的Docker镜像,大大简化了构建步骤。安装模拟器DockerforLinux不支持构建 arm 架构镜像,我们可以运行一个新的容器让其支......
  • 丝滑解决ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_
    基础环境:MacOSm1、python=3.9前情提要:在Anaconda终端运行代码的时候,显示报错:importError:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:version`GLIBCXX_3.4.29'notfound1问题分析:根据提示是/usr/lib/x86_64-linux-gnu/路径下的libstdc++.so.6缺少版本GLIBCXX_3.4.29解......