Docker的部署安装(CentOS)-by paymob
2024-09-03 03:54:10
环境准备
通过命令查看系统版本和内核版本等信息
[gmuser@--- ~]$ cat /etc/redhat-release
CentOS Linux release 7.2. (Core)
[gmuser@--- ~]$ uname -a
Linux --- 3.10.-327.18..el7.x86_64 # SMP Thu May :: UTC x86_64 x86_64 x86_64 GNU/Linux
[gmuser@--- ~]$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID=""
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION=""
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION=""
为用户提权(sudo)
[gmuser@--- ~]$ sudo install
[sudo] password for gmuser:
Sorry, try again. [sudo] password for gmuser:
gmuser is not in the sudoers file. This incident will be reported.
[gmuser@--- ~]$ su root Password:
[root@--- gmuser]# vim /etc/sudoers ## Allow root to run any commands anywhere root ALL=(ALL) ALL gmuser ALL=(ALL) ALL ## Allows members of the 'sys' group to run networking, software, ## service management apps and more. # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS ## Allows people in group wheel to run all commands
保存退出
操作系统需求
为兼容企业级应用,学习选用Centos7做为部署安装Docker的系统平台
更换默认的yum源
Centos默认的yun源在国外,速度很慢有时间也无法访问
[gmuser@--- ~]$ yum repolist [gmuser@--- ~]$ vi /etc/hosts [gmuser@--- ~]$ ping mirrors.aliyun.com 更换成aliyun yum 源 [root@--- /]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak [root@--- /]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@--- /]# vi /etc/yum.repos.d/CentOS-Base.repo
Yum运行下面的命令生成缓存
[root@--- /]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@--- /]# yum makecache
[root@--- /]# yum repolist
删除docker旧版本
[gmuser@--- /]$ sudo yum remove docker docker-common docker-selinux docker-engine
[sudo] password for gmuser:
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: docker-selinux
No Match for argument: docker-engine
No Packages marked for removal
安装 Docker CE
[gmuser@--- /]$ sudo yum remove docker docker-common docker-selinux docker-engine
[gmuser@--- /]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[gmuser@--- /]$ sudo yum install -y docker-ce
若需要安装指定的版本时,可参照以下命令
启动docker
[gmuser@--- /]$ sudo systemctl start docker
[gmuser@--- /]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [gmuser@--- /]$
升级和卸载docker
使用阿里镜像加速器
使用阿里云专属加速器加快获取Docker官方镜像,否则在国内速度会慢到你无法忍受哒。步骤如下:
- 免费注册一个阿里云账号 www.aliyun.com
- 进入加速器页面 https://cr.console.aliyun.com/#/accelerator
- 选择
镜像加速器
按图中进行相关配置
参考文档:
最新文章
- Android如何制作漂亮的自适布局的键盘
- SQL Server2000清除数据库日志
- crontab 管理指定用户的定时任务
- Parallel.js初探续集
- Web3D编程总结——3D碰撞检测初探
- Winform中调用js函数
- 六天玩转javascript:javascript变量与表达式(1)
- 安装JAVA JDK注意事项
- Linux命令 + Shell
- 使用like时left outer join和inner join的区别
- 为什么使用spring Struts 等框架开发
- 遇见Lambda
- Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLIC
- Html +++++css总结
- OSW 快速安装部署
- [51nod1532]带可选字符的多字符串匹配
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9
- appium+夜神模拟器+python安卓app爬虫初体验
- 写给深圳首期Python自动化开发周未班的信
- 互评Final版本——可以低头,但没必要——取件帮