linux环境安装docker和dockercompose 命令页表快速完成

简介: 此文目的,  如果你熟悉docker, 就没必要每次都去一个一个命令开始复制 粘贴 执行 浪费时间.  直接把整理好的所有命令放入一次执行即可. 如果你是小白, 需要直接搭建环境成功,看到直观效果, 这里就可以.
此文目的, 
  1. 如果你熟悉docker, 就没必要每次都去一个一个命令开始复制 粘贴 执行 浪费时间.  直接把整理好的所有命令放入一次执行即可.
  2. 如果你是小白, 需要直接搭建环境成功,看到直观效果, 这里就可以. 可以增长信息,提升学习兴趣. 不至于浪费时间太多,热情冷却.

docker快速直接执行:

#Uninstall old versions
O#lder versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated 
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

#SET UP THE REPOSITORY
#Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
 sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

#Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
 sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

#Optional: Enable the edge and test repositories. These repositories are included in the docker.repo file above but are disabled by default. You can enable them alongside the stable repository.
sudo yum-config-manager --enable docker-ce-edge
sudo yum-config-manager --enable docker-ce-test
#You can disable the edge or test repository by running the yum-config-manager command with the --disable flag. To re-enable it, use the --enable flag. The following command disables the edge repository.
sudo yum-config-manager --disable docker-ce-edge

#INSTALL DOCKER CE
#Install the latest version of Docker CE, or go to the next step to install a specific version:
sudo yum install docker-ce

#If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it
#Got multiple Docker repositories?
#If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install or yum update command always installs the highest possible version, which may not be appropriate for your stability needs.
#Docker is installed but not started. The docker group is created, but no users are added to the group.
#To install a specific version of Docker CE, list the available versions in the repo, then select and install:
#a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
yum list docker-ce --showduplicates | sort -r

#Start Docker.
sudo systemctl start docker

#Verify that docker is installed correctly by running the hello-world image.
 sudo docker run hello-world

AI 代码解读
docker-compose快速直接执行:
#Run this command to download the latest version of Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

#Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose

#Test the installation.
docker-compose --version
AI 代码解读


参考:

安装docker和docker-compose

具体安装步骤:

注意:Docker安装要求Linux 3.10以上版本,用uname -a命令可查看到。

安装之后,可查看版本:

$ docker -v
$ docker-compose -v

然后把当前用户加到docker用户组里面:

$ sudo gpasswd -a ${USER} docker

就不用每次启动Docker都得加sudo了。

注意,执行gpasswd命令之后要重新登陆才有效。

来源: https://www.awaimai.com/2120.html


阿里云服务器在搞限时活动优惠卷, 100多个产品通用, 需要的自取. 注意, 领取的优惠券30天内有效,尽快使用!
领取链接:
https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=s306eooi&utm_source=s306eooi

目录
打赏
0
0
0
0
3
分享
相关文章
推荐Linux环境下效能优良的双向文件同步工具
综合上述条件,对于Linux环境下的双向文件同步需求,Unison 和 Syncthing 是两个非常出色的选择。它们都有良好的社区支持和文档资源,适用于不同规模的环境,从个人使用到商业部署。Unison 特别适合那些需要手动干预同步过程、需要处理文件冲突解决的场景。而 Syncthing 更加现代化,适合需要自动、实时的数据同步与备份的环境。对于选择哪一个,这将取决于个人的使用场景和具体需求。
55 16
Docker run命令-p参数详解
本文介绍Docker端口映射的基础用法。通过`docker run -p <宿主机端口>:<容器端口>`实现端口映射,例如`-p 5000:80`将宿主机5000端口映射到容器80端口,外部访问宿主机5000端口时流量会转发至容器内部的80端口。示例命令中,`-d`用于后台运行,`--restart=always`确保容器自动重启,`--name`指定容器名称。部署完成后可通过`http://服务器IP地址:5000`验证服务是否正常运行。
linux命令—tree
tree是一款强大的Linux命令行工具,用于以树状结构递归展示目录和文件,直观呈现层级关系。支持多种功能,如过滤、排序、权限显示及格式化输出等。安装方法因系统而异常用场景包括:基础用法(显示当前或指定目录结构)、核心参数应用(如层级控制-L、隐藏文件显示-a、完整路径输出-f)以及进阶操作(如磁盘空间分析--du、结合grep过滤内容、生成JSON格式列表-J等)。此外,还可生成网站目录结构图并导出为HTML文件。注意事项:使用Tab键补全路径避免错误;超大目录建议限制遍历层数;脚本中推荐禁用统计信息以优化性能。更多详情可查阅手册mantree。
linux命令—tree
linux命令—cd
`cd` 命令是 Linux/Unix 系统中用于切换工作目录的基础命令。支持相对路径与绝对路径,常用选项如 `-L` 和 `-P` 分别处理符号链接的逻辑与物理路径。实际操作中,可通过 `cd ..` 返回上级目录、`cd ~` 回到家目录,或利用 `cd -` 在最近两个目录间快速切换。结合 Tab 补全和 `pwd` 查看当前路径,能显著提升效率。此外,需注意特殊字符路径的正确引用及脚本中绝对路径的优先使用。
|
29天前
|
Linux命令拓展:为cp和mv添加进度显示
好了,就这样,让你的Linux复制体验充满乐趣吧!记住,每一个冷冰冰的命令背后,都有方法让它变得热情起来。
101 8
|
1月前
|
Linux环境下VSCode快速安装终极指南:debian/ubuntu/linux平台通用
以上就是在Linux环境下安装VSCode的终极指南,抛开繁复的专业词汇,以平易近人的文字、形象生动的比喻让你轻松学会这一过程。别忘了,你的小伙伴VSCode已经在应用菜单里等你了!
366 23
Linux环境下必备的基础命令概览
以上就是Linux系统中的基本命令和工具,掌握它们就能帮你在Linux世界里游刃有余。这其实就像是学习驾驭一辆新车,熟悉了仪表盘,调整好了座椅,之后的旅程就只需要享受风驰电掣的乐趣了。
49 4
详解Ubuntu的strings与grep命令:Linux开发的实用工具。
这就是Ubuntu中的strings和grep命令,透明且强大。我希望你喜欢这个神奇的世界,并能在你的Linux开发旅程上,通过它们找到你的方向。记住,你的电脑是你的舞台,在上面你可以做任何你想做的事,只要你敢于尝试。
169 32
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等