首页 > 系统相关 >Linux搭建docker

Linux搭建docker

时间:2023-04-11 22:23:17浏览次数:45  
标签:x86 stabledocker ce 64 Linux docker el7 搭建


### 1. 查看系统的内核版本

```bash
[root@wide ~]# uname -r
3.10.0-1160.el7.x86_64
```

### 2. 将yum更新到最新版本

```bash
[root@wide ~]# yum upate -y
Complete!
```

### 3. 安装Docker所需的依赖包

```bash
[root@wide ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.qlu.edu.cn
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Package device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 already installed and latest version
Package 7:lvm2-2.02.187-6.el7_9.5.x86_64 already installed and latest version
Nothing to do
[root@wide ~]#
```

### 4.设置Docker的yum的源

```bash
[root@wide ~]# sudo 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
```

### 5. 查看仓库所有Docker版本

```bash
[root@wide ~]# yum list docker-ce --showduplicates | sort -r
* updates: mirrors.qlu.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
* extras: mirrors.bupt.edu.cn
docker-ce.x86_64 3:23.0.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.24-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.23-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.22-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
* base: mirrors.bupt.edu.cn
Available Packages
```

### 6. 安装Docker

```bash
[root@wide ~]# yum install docker-ce -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.qlu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:23.0.3-1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-23.0.3-1.el7.x86_64
--> Processing Dependency: containerd.io >= 1.6.4 for package: 3:docker-ce-23.0.3-1.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-23.0.3-1.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-23.0.3-1.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package containerd.io.x86_64 0:1.6.20-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:23.0.3-1.el7 will be installed
--> Processing Dependency: docker-buildx-plugin for package: 1:docker-ce-cli-23.0.3-1.el7.x86_64
--> Processing Dependency: docker-compose-plugin for package: 1:docker-ce-cli-23.0.3-1.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:23.0.3-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-23.0.3-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-23.0.3-1.el7.x86_64
--> Running transaction check
---> Package docker-buildx-plugin.x86_64 0:0.10.4-1.el7 will be installed
---> Package docker-compose-plugin.x86_64 0:2.17.2-1.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================================
Installing:
docker-ce x86_64 3:23.0.3-1.el7 docker-ce-stable 23 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
containerd.io x86_64 1.6.20-3.1.el7 docker-ce-stable 34 M
docker-buildx-plugin x86_64 0.10.4-1.el7 docker-ce-stable 12 M
docker-ce-cli x86_64 1:23.0.3-1.el7 docker-ce-stable 13 M
docker-ce-rootless-extras x86_64 23.0.3-1.el7 docker-ce-stable 8.8 M
docker-compose-plugin x86_64 2.17.2-1.el7 docker-ce-stable 12 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k

Transaction Summary
.............
Installed:
docker-ce.x86_64 3:23.0.3-1.el7

Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.20-3.1.el7 docker-buildx-plugin.x86_64 0:0.10.4-1.el7 docker-ce-cli.x86_64 1:23.0.3-1.el7
docker-ce-rootless-extras.x86_64 0:23.0.3-1.el7 docker-compose-plugin.x86_64 0:2.17.2-1.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8

Complete!
```

### 7.启动Docker并添加开机自启动

```bash
[root@wide ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@wide ~]# systemctl start docker
[root@wide ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-04-10 23:41:28 PDT; 26s ago
Docs: https://docs.docker.com
Main PID: 4709 (dockerd)
Tasks: 8
Memory: 107.6M
CGroup: /system.slice/docker.service
└─4709 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Apr 10 23:41:27 wide dockerd[4709]: time="2023-04-10T23:41:27.274527839-07:00" level=info msg="[core] [Channel #4] Channel Connectivity change to READY" module=grpc
Apr 10 23:41:27 wide dockerd[4709]: time="2023-04-10T23:41:27.300770723-07:00" level=info msg="Loading containers: start."
Apr 10 23:41:27 wide dockerd[4709]: time="2023-04-10T23:41:27.940276724-07:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Dae... IP address"
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.094586748-07:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.179894757-07:00" level=info msg="Loading containers: done."
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.213789267-07:00" level=info msg="Docker daemon" commit=59118bf graphdriver=overlay2 version=23.0.3
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.214098003-07:00" level=info msg="Daemon has completed initialization"
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.236177099-07:00" level=info msg="[core] [Server #7] Server created" module=grpc
Apr 10 23:41:28 wide systemd[1]: Started Docker Application Container Engine.
Apr 10 23:41:28 wide dockerd[4709]: time="2023-04-10T23:41:28.239927052-07:00" level=info msg="API listen on /run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@wide ~]#
```
![在这里插入图片描述](/i/ll/?i=613824ae9afe4488b631fbedb8e380b3.png)

### 8.查看docker版本

```bash
[root@wide ~]# docker --version
Docker version 23.0.3, build 3e7cbfd
```

### 9.卸载 Docker

```bash
[root@wide ~]#sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine
```

### 10.安装 Portainer

1.创建目录

```bash
[root@wide ~]# mkdir -p /data/portainer/data /data/portainer/public
```

创建一个 portainer 下的放置扩展包public文件夹
2.可以对这个扩展包进行汉化可以将汉化开展放到public下
3. 创建 portainer 卷

```bash
[root@wide ~]# docker volume create portainer_data
portainer_data
```

4.拉取最新的 Portainer

```bash
[root@wide ~]# docker pull portainer/portainer
Using default tag: latest
latest: Pulling from portainer/portainer
```

5.安装和启动
第一种:

```bash
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
```

第二种:

```bash
docker run -d --restart=always --name portainer -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /data/portainer/data:/data -v /data/portainer/public:/public portainer/portainer
```

```bash
[root@laona portainer]# docker run -d --restart=always --name portainer -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /data/portainer/data:/data -v /data/portainer/public:/public portainer/portainer
a29864c820494afe3e465ce9b58e686851f5c6526532fe52fc4b83c1cc0b705e
```

• -v 为挂载本地文件路径到 Docker 中,用法为:-v 本地路径:docker中的路径
5.1如果防火墙开启中,需要开放端口,不然在第六步访问不了

```bash
firewall-cmd --zone=public --add-port=9000/tcp --permanent
```

6.访问 Portainer
• 地址:<http://【ip地址】:9000/>
• 操作:登录后设置你的用户名和密码,并设置本地Docker即可

 

标签:x86,stabledocker,ce,64,Linux,docker,el7,搭建
From: https://www.cnblogs.com/wideskylqz/p/17308011.html

相关文章

  • Linux umount 命令
    Linuxumount命令Linuxumount(英文全拼:unmount)命令用于卸除文件系统。umount可卸除目前挂在Linux目录中的文件系统。语法umount[-ahnrvV][-t<文件系统类型>][文件系统]参数:-a卸除/etc/mtab中记录的所有文件系统。-h显示帮助。-n卸除时不要将信息存入/etc/mtab文件......
  • Code-C++-Linux-统计一个文件夹占据空间大小
    Code-C++-Linux-统计一个文件夹占据空间大小https://my.oschina.net/Tsybius2014/blog/330628从以上链接中拷贝的代码#include<stdio.h>#include<sys/stat.h>#include<sys/types.h>#include<unistd.h>#include<stdlib.h>#include<dirent.h>#incl......
  • Linux 文件系统之 inode小结
    Linux文件系统之inode小结inode是一个重要概念,是理解Unix/Linux文件系统和硬盘储存的基础。一、inode是什么?理解inode,要从文件储存说起。文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector)。每个扇区储存512字节(相当于0.5KB)。操作系统读取硬盘的时候,不会一个个扇区地读......
  • 利用Samba共享window、Linux文件
    利用Samba共享Linux和window之间的文件1、安装Samba服务器#yum-yinstallsambasamba-client2、创建共享目录及更改权限#mkdirSharedir//自己取一个喜欢的名字#chmod777Sharedir-R//给的是最高读写权限,请根据实际需要给相应的权限3、添加用户#useraddTunan/......
  • OpenEuler Linux 部署 HadoopHA
    OpenEulerLinux部署HadoopHAopenEulerLinux部署HadoopHA主机名IP地址spark01192.168.28.11spark02192.168.28.12spark03192.168.28.13升级操作系统和软件yum-yupdate升级后建议重启安装常用软件yum-yinstallgccgcc-c++autoconfautom......
  • openEuler Linux 部署 Zookeeper 集群
    openEulerLinux部署Zookeeper集群openEulerLinux部署Zookeeper集群主机名IP地址spark01192.168.28.11spark02192.168.28.12spark03192.168.28.13升级操作系统和软件yum-yupdate升级后建议重启安装常⽤软件yum-yinstallgccgcc-c++......
  • docker-docker介绍
    1.docker介绍1.1虚拟化技术和相关概念在计算机中,虚拟化(Virtualization)是一种资源管理技术,是将计算机的各种实体资源,如服务器、网络、内存及存储等,予以抽象转换后呈现出来,打破实体结构间不可切割的障碍,使用户可以比原本的组态更好的方式来应用这些资源。这些资源的新虚拟部门......
  • Linux mount命令
    Linuxmount命令这个命令很重要,但是个人OS没使用过,都是在项目部署的时候弹性云主机上挂载数据盘Linuxmount命令是经常会使用到的命令,它用于挂载Linux系统外的文件。语法mount[-hV]mount-a[-fFnrsvw][-tvfstype]mount[-fnrsvw][-ooptions[,...]]device|dirmoun......
  • Linux操作系统基础的常用命令
    1,Linux简介Linux是一种自由和开放源码的操作系统,存在着许多不同的Linux版本,但它们都使用了Linux内核。Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、台式计算机。1.1Linux介绍Linux出现于1991年,是由芬兰赫尔辛基大学学生LinusTorvalds和后来加入的众多爱好者......
  • Linux操作系统进程的状态和转换(五态模型)
    1、进程的状态和装换1.1进程的三态模型按进程在执行过程中的不同情况至少要定义三种状态:运行(running)态:进程占有处理器正在运行的状态。进程已获得CPU,其程序正在执行。在单处理机系统中,只有一个进程处于执行状态;在多处理机系统中,则有多个进程处于执行状态。就绪(ready)态:进程具......