简体   繁体   English

在 Amazon Linux AMI 上升级 Docker

[英]Upgrading Docker on Amazon Linux AMI

I want to upgrade Docker to v1.8 on Amazon Linux.我想在 Amazon Linux 上将 Docker 升级到 v1.8。

At the time of writing their internal yum package repository has: Docker version 1.7.1, build 786b29d/1.7.1 .在撰写本文时,他们的内部 yum 包存储库有: Docker version 1.7.1, build 786b29d/1.7.1

Things I have already tried我已经尝试过的事情

Manually installing from the Docker project's repoDocker 项目的 repo手动安装

Error: Package: docker-engine-1.8.2-1.el7.centos.x86_64 (dockerrepo) Requires: systemd-units错误:包:docker-engine-1.8.2-1.el7.centos.x86_64 (dockerrepo) 要求:systemd-units

If you're using the EC2 Container service, the AWS ECS-optimized AMI (2015.09.b) is running docker-1.7.1 as of this writing.如果您使用的是 EC2 容器服务,则在撰写本文时, AWS ECS 优化的 AMI (2015.09.b) 正在运行 docker-1.7.1。 A post in the AWS forums states "[AWS is] testing 1.9 RC and plan to deliver it this month." AWS 论坛上的一篇帖子称“[AWS 正在测试 1.9 RC,并计划在本月交付”。

To expand on Hzmy's answer, here's how to upgrade Docker to 1.9.0 in an SSH session:为了扩展 Hzmy 的答案,以下是在 SSH 会话中将 Docker 升级到 1.9.0 的方法:

service docker stop
cp /usr/bin/docker /usr/bin/docker.old
curl -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-1.9.0
service docker start

If you're using CloudFormation templates, here's a command you can drop in your AWS::Cloudformation::Init :如果您使用 CloudFormation 模板,可以在AWS::Cloudformation::Init中添加以下命令:

...
"commands": {
    ...,
    "03_upgrade_docker_for_log_driver_support": {
        "command": {
            "Fn::Join": [
                "",
                [
                    "#!/bin/bash -xe\n",
                    "service docker stop\n",
                    "cp /usr/bin/docker /usr/bin/docker.old\n",
                    "curl -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-1.8.3\n",
                    "service docker start\n"
                ]
            ]
        }
    }
    ...
}
...

Maybe not the cleanest, but it seems to work for me.也许不是最干净的,但它似乎对我有用。

I ended up installing the Amazon Linux docker package and then overwriting the /usr/bin/docker binary with the 1.8.2 version binary from: https://docs.docker.com/installation/binaries/ .我最终安装了 Amazon Linux docker包,然后用来自https://docs.docker.com/installation/binaries/的 1.8.2 版本二进制文件覆盖了/usr/bin/docker二进制文件。

Not exactly elegant - but all of the dependencies are the same, and seeing as my AMI is immutable the package won't be upgraded on top of the current image.不完全优雅 - 但所有依赖项都是相同的,并且由于我的 AMI 是不可变的,因此不会在当前映像之上升级包。

I just put this answer here for more people to find it, but all the credits to Archimedes Trajano .我只是把这个答案放在这里让更多人找到它,但所有功劳都归功于Archimedes Trajano

The only thing I corrected is that haveged installation is not necessary on the latest Amazon Linux 2 LTS Candidate.我唯一更正的是,在最新的 Amazon Linux 2 LTS Candidate 上不需要安装haveged Also, since SELinux is disabled by default on Amazon Linux, so all the steps realated to SELinux are not necessary too, but container-selinux is required by docker-ce , so it must be installed anyway.此外,由于在 Amazon Linux 上默认禁用 SELinux,因此所有与 SELinux 相关的步骤也不是必需的,但 docker docker-ce需要container-selinux ,因此无论如何都必须安装它。 Firewall enabling is optional here.防火墙启用在这里是可选的。

So, final steps for latest Amazon 2 AMI could look like this:因此,最新的 Amazon 2 AMI 的最后步骤可能如下所示:

yum install -q -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.99-1.el7.noarch.rpm
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -q -y firewalld docker-ce
systemctl enable firewalld
systemctl start firewalld
firewall-cmd --add-port=2377/tcp --permanent
firewall-cmd --add-port=2376/tcp --permanent
firewall-cmd --add-port=7946/tcp --permanent
firewall-cmd --add-port=7946/udp --permanent
firewall-cmd --add-port=4789/udp --permanent
firewall-cmd --zone=public --permanent --add-masquerade
firewall-cmd --reload
usermod -a -G docker ec2-user
systemctl enable docker
systemctl start docker

All the steps should be ran with sudo .所有步骤都应使用sudo运行。 Non-sudo docker run will be available after reboot/relogin upon execution of these commands.执行这些命令后重新启动/重新登录后,非 sudo docker run 将可用。

将 docker 更新到最新版本对我有用

sudo yum upgrade docker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM