如何在 AWS EC2 中启动 docker?

How to start docker in AWS EC2?

我已经启动了一个基于 Amazon Linux2 AMI(HVM)、SSD 卷类型的 EC2 实例。我想在那个实例中安装 docker。我 运行 以下命令:

sudo yum update -y
sudo yum install -y docker
sudo chkconfig docker on
chkconfig --list docker 

我在 putty 会话中收到以下消息:

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

error reading information on service docker: No such file or directory

我认为 Docker 已经安装好了,但在我发现

的 putty 日志中它不是 starting.Because
Installed:
docker.x86_64 0:18.06.1ce-8.amzn2

当我发出命令时

sudo chkconfig docker on

腻子告诉我:

Note.Forwarding request to 'systemctl enable docker.service'

所以我什至尝试了

sudo systemctl enable docker.service

我必须使用其他 AMI 吗?

如果您使用的是 ECS,除非您有理由使用自定义 AMI,否则您应该使用受支持的 ECS 优化 AMI。这些 AMI 预先配置了 docker 和所有其他 ecs 要求:

The Amazon ECS-optimized AMIs are preconfigured with these requirements and recommendations. We recommend that you use the Amazon ECS-optimized Amazon Linux 2 AMI for your container instances unless your application requires a specific operating system or a Docker version that is not yet available in that AMI.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html