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. A post in the AWS forums states "[AWS is] testing 1.9 RC and plan to deliver it this month."
To expand on Hzmy's answer, here's how to upgrade Docker to 1.9.0 in an SSH session:
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:
...
"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.
Answer from Pete on Stack OverflowNot sure how to update Amazon Linux 2 packages for docker container
Upgrading Docker on Amazon Linux AMI - Stack Overflow
Updating docker engine and docker compose plugin in Amazon Linux 2?
How do I install docker version 27.3.1 on Amazon Linux 2023?
Hi I have a docker container with the latest python image. When scanned there are certain vulnerabilities that can be solved by updating the Amazon Linux 2 packages. I am not sure how to do that because I have a python image and not linux.
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. A post in the AWS forums states "[AWS is] testing 1.9 RC and plan to deliver it this month."
To expand on Hzmy's answer, here's how to upgrade Docker to 1.9.0 in an SSH session:
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:
...
"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/.
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.
To get Docker running on the AWS AMI you should follow the steps below (these are all assuming you have ssh'd on to the EC2 instance).
Update the packages on your instance
[ec2-user ~]$ sudo yum update -yInstall Docker
[ec2-user ~]$ sudo yum install docker -yStart the Docker Service
[ec2-user ~]$ sudo service docker startAdd the ec2-user to the docker group so you can execute Docker commands without using sudo.
[ec2-user ~]$ sudo usermod -a -G docker ec2-user
You should then be able to run all of the docker commands without requiring sudo. After running the 4th command I did need to logout and log back in for the change to take effect.
The hardest part to figure all of this out was the container-selinux requirement. Just find the latest version in http://mirror.centos.org/centos/7/extras/x86_64/Packages/ and install that first. In addition EC2 instances may not have a proper entropy generator so haveged may need to be installed.
The rest is taken from https://docs.docker.com/install/linux/docker-ce/centos/ with the addition of haveged and firewalld. All these have to be done as root so sudo appropriately.
yum install -q -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.42-1.gitad8f0f7.el7.noarch.rpm
yum install -q -y http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/h/haveged-1.9.1-1.el7.x86_64.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
systemctl enable haveged
systemctl start haveged
systemctl enable docker
systemctl start docker
setenforce 1
Enable SELinux by modifying /etc/sysconfig/selinux to be
SELINUX=enforcing
SELINUXTYPE=targeted
Then reboot your instance by issuing shutdown -r now
Executing sudo docker version should yield as of the time of this posting...
Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:09:15 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm Server: Engine: Version: 18.03.0-ce API version: 1.37 (minimum version 1.12) Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:13:03 2018 OS/Arch: linux/amd64 Experimental: false
Install Docker
sudo yum update -y
sudo yum -y install docker
Start Docker
sudo service docker start
Access Docker commands in ec2-user user
sudo usermod -a -G docker ec2-user
sudo chmod 666 /var/run/docker.sock
docker version
So sorry, it was my misunderstanding. My OS is Redhat Linux. I get to install docker by
yum-config-manager --enable rhui-REGION-rhel-server-extras
sudo yum -y install docker
systemctl start docker
systemctl enable docker
docker version