Open caroundsky opened 1 year ago
$ sudo apt-get update
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release
为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
然后,我们需要向 sources.list 中添加 Docker 软件源
$ echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
### 安装:
$ curl -fsSL get.docker.com -o get-docker.sh $ sudo sh get-docker.sh
### 测试安装是否成功:
若输出以下信息,则安装成功
$ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24 Status: Downloaded newer image for hello-world:latest
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/
For more examples and ideas, visit: https://docs.docker.com/get-started/
## 安装docker-compose
// 安装
$ sudo curl -L https://github.com/docker/compose/releases/download/v2.17.0/docker-compose-`uname -s-
uname -m` > /usr/local/bin/docker-compose
// 授权 $ sudo chmod +x /usr/local/bin/docker-compose
* Tips:
- [docker-compose版本源](https://github.com/docker/compose/releases)
- 注意下载安装指令有坑点:`uname -s`-`uname -m` 输出的是当前的系统和内核版本,当前用的为 Linux & x86_64,即输出`Linux-x86_64`,这个拼接出来的与版本源的下载地址(linux-x86_64)大小写不对,因此会安装失败。因此显式的指定下载源来解决问题。
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.0/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
### 测试安装是否成功:
docker-compose version
在MobaXterm使用root用户登录
EC2的默认配置是使用ec2-user账号登陆的,对很多文件夹是没有权限的,因此先要去配置root权限;
sudo passwd root
;su root
;使用root身份编辑亚马逊云主机的ssh登录方式
vi /etc/ssh/sshd_config
,将以下改为yes,:wq退出:sudo /sbin/service sshd restart
root
即可成功登录