首先先安装Docker
检查Docker版本
docker --version
安装Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
设置权限
sudo chmod +x /usr/local/bin/docker-compose
查看版本
sudo docker compose version
测试是否可以使用
mkdir compose-test
cd compose-test
新建一个docker-compose.yml文件
sudo vi docker-compose.yml
写入
version: '2'
services:
hello-world:
image:
hello-world:latest
构建
sudo docker compose up
输出
Output
✔ hello-world 1 layers [⣿] 0B/0B Pulled 2.6s
✔ 2db29710123e Pull complete 0.6s
[+] Running 2/1
✔ Network compose-test_default Created 0.2s
✔ Container compose-test-hello-world-1 Created 0.1s
Attaching to compose-test-hello-world-1
compose-test-hello-world-1 |
compose-test-hello-world-1 | Hello from Docker!
compose-test-hello-world-1 | This message shows that your installation appears to be working correctly.
卸载
sudo rm /usr/local/bin/docker-compose
sudo dnf remove docker-compose
sudo dnf autoremove
标签:compose,AlmaLinux,sudo,hello,Compose,test,world,Docker,docker From: https://www.cnblogs.com/HGNET/p/17379182.html