1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 阿里云服务器centos7 安装docker 和docker-compose 及相关命令

阿里云服务器centos7 安装docker 和docker-compose 及相关命令

时间:2022-11-04 10:10:55

相关推荐

阿里云服务器centos7 安装docker 和docker-compose 及相关命令

推荐用阿里云的容器服务

环境检测更新

环境检测

Docker 要求 CentOS 系统的内核版本高于 3.10

uname -r#输出3.10.0-862.14.4.el7.x86_64

更新

yum -y update

创建用户及用户组

useradd docker

设置用户密码

passwd docker

随后要输入2次密码

安装docker

执行自动安装命令

curl -fsSL / | sh

执行

usermod -aG docker docker

启动

设置启动和开机启动

systemctl start dockersystemctl enable docker

切换到docker用户下

方式一

su docker

方式二

退出root用户,使用docker用户登录

下载和运行hello-world镜像容器

要在 docker 用户下操作,不能在 root 用户下操作

下载镜像

docker pull hello-world

运行容器

docker run hello-world

输出

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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:/For more examples and ideas, visit:/get-started/

docker版本

docker --version

docker-compose 安装

官方文档

/compose/

源码地址

/docker/compose

最新正式版

/docker/compose/releases/latest

打开如上地址后,有如下安装地址,直接复制到终端进行安装

curl -L /docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose

docker-compose 版本

docker-compose --version

docker 镜像加速器

/fenglailea/article/details/84301839

清空所有镜像

方式一

docker rmi -f $(docker images -qa)

方式二

docker system prune --volumesdocker system prune -a

该命令清除:

所有停止的容器所有不被任何一个容器使用的网络所有不被任何一个容器使用的volume所有无实例的镜像

/weixin_42189048/article/details/106530444

强制删除

docker image rm -f IMAGE ID案例docker image rm -f bcb0d5f1f539

FAQ

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。