Went to launch an Amazon Linux AMI 2014.09.1 (HVM) - ami-6e7bd919 earlier, claiming that:
It includes the 3.14 kernel, Ruby 2.1, PHP 5.5, PostgreSQL 9.3, Docker 1.2, the AWS command line tools, and repository access to many other packages.
First thing I do when I login:
[ec2-user#ip-123-45-67-89 ~]$ docker
-bash: docker: command not found
Am I missing something obvious?
To be 100% precise : Amazon Linux ships with Docker's kernel extensions built-in but the docker CLI needs to be installed from the repository, as explained in other answers
You can run the command to confirm
$ yum list installed |grep docker
So you didn't find the pakcage docker to be installed.
But if you list it, it's there. It is ready for you to install it.
$ yum list |grep docker
docker.x86_64 1.3.3-1.0.amzn1 amzn-updates
docker-devel.x86_64 1.3.3-1.0.amzn1 amzn-updates
docker-pkg-devel.x86_64 1.3.3-1.0.amzn1 amzn-updates
Then you can run yum install docker to install it.
# yum install docker
...
# which docker
/usr/bin/docker
Just try these steps. I think the most easiest way to make it done.
-sudo yum update
-sudo yum install -y docker
-sudo service docker start
Check if docker is running by docker -v and it will return
Docker version 1.3.1, build c78088f/1.3.1
Try yum install docker. Docker is in the repo but not pre installed.
Related
I'm trying to install php 8.1 on a Graviton 2 (ARM64) EC2 instance thats running Amazon Linux 2.
All of the guides I've followed use remi-release-7.rpm. When I use this repository, yum updates are flooded with 404 errors like
http://rpms.remirepo.net/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Is there a relatively easy way to install PHP 8.1 on this type of instance?
You can build it from source. I was able to install it on Amazon Linux 2 on Graviton (aarch64, 5.10 kernel) using the steps below. Be sure to update the url in the wget command to the latest available version or what ever you want to build.
sudo yum -y groupinstall "Development Tools" "Development Libraries"
sudo yum -y install libxml2-devel sqlite-devel
wget https://www.php.net/distributions/php-8.1.5.tar.xz
tar -xf php-8.1.5.tar.xz
cd php-8.1.5/
./configure
make -j$(nproc)
sudo make -j$(nproc) install
Alternatively, you could just use a container. You can get one from Amazon ECR here: https://gallery.ecr.aws/docker/library/php
docker pull public.ecr.aws/docker/library/php:8.1-rc-apache-bullseye
Amazon Linux 2 now has built-in support for PHP 8.1 including ARM!
https://repost.aws/questions/QUsfhDbww4SAy8i5Jmd4vcMg/amazon-linux-2-amazon-linux-extras-php-8-1-support
I'm trying build an image for use on EC2 instances in an AWS Batch job. I need to use Ubuntu 18.04 because the goal is to run some Fortran software that I can only get to compile on Ubuntu 18.04. I have the Fortran software and some python scripts running well on a manually started Ubuntu 18.04 EC2 instance.
Now, I'm trying to build an image with Docker (that I'll eventually apply to 100s or 1000s of EC2 instances)... but I have to get CloudWatchAgent (CWA) installed and started, and I can't get CWA to start in the Docker build. CWA starts and runs fine in my manual EC2 development instance (Ubuntu 18.04). I initially had problems with CWA in my manual instance because CWA uses systemctl, and so I had to manually install systemd, and that worked after a reboot. But, I'm not able to replicate this in my Docker build, but always get the error:
System has not been booted with systemd as init system (PID 1). Can't operate.
unknown init system
The command '/bin/sh -c sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:amazon-cloudwatch-agent.json' returned a non-zero code: 1
I tried starting with an ubuntu 18.04 image that is supposed to have systemd already installed, and tried rebooting my EC2 instance, same error. Here's the source: https://hub.docker.com/r/jrei/systemd-ubuntu
I looked for other ideas, e.g.: Docker System has not been booted with systemd as init system
... but couldn't figure out how to make it work in a Docker build.
So,
am I using the Ubuntu 18.04 image (that has systemd) in my build wrong- how to use in a Docker build?
is there another way to start CloudWatchAgent in Ubuntu 18.04 that gets around the systemd problem?
would it work/is there a way to restart the operating system inside the Docker container, during the docker build stage?
am I stuck and will have to try recompile everything on a different Ubuntu or AMI like Amazon Linux?
Or is there something else I'm missing?
Here's my Docker file:
#version with systemd already installed
FROM jrei/systemd-ubuntu#sha256:1b65424e0ec4f6772576b55c49e1470ba506504d1033e9da5795785b1d6a4d88 as ubuntu-base
RUN apt-get update && apt-get install -y \
sudo \
wget \
python3-pip
RUN sudo apt-get -y install libgfortran3
RUN sudo pip3 install boto3
RUN wget https://s3.us-east-2.amazonaws.com/amazoncloudwatch-agent-us-east-2/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
RUN sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
COPY . .
RUN cp amazon-cloudwatch-agent.json /opt/aws/amazon-cloudwatch-agent/etc/
ENV ECS_AVAILABLE_LOGGING_DRIVERS = awslogs
RUN sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:amazon-cloudwatch-agent.json
RUN mkdir -p cpseqlogs
CMD python3 cpsequence.py
Thanks for any suggestions, ideas, or tips (I'm fairly new to Docker, but not totally green on linux).
I wanna create docker image for Amazon ECR.
but yum can't find it in my Amazon Linux2.
[root#*** ~]# yum install -y docker
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
No package docker available.
Error: Nothing to do
Next, I tried to use amazon-linux-extras.
but amazon-linux-extras is not found, too.
[root#*** ~]# amazon-linux-extras install docker -y
-bash: amazon-linux-extras: command not found
[root#*** ~]# find / -name 'amazon-linux-extras'
[root#*** ~]$ cat /proc/version
Linux version 4.14.77-81.59.amzn2.x86_64 (mockbuild#ip-10-0-1-59) (gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)) #1 SMP Mon Nov 12 21:32:48 UTC 2018
How can I install amazon-linux-extras or create docker image?
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
yum -y install docker
systemctl start docker
systemctl enable docker
docker version
Make sure you have amazon-linux-extras installed
[root#ip-20-0-0-112 ~]# which amazon-linux-extras
/usr/bin/amazon-linux-extras
If not install amazon-linux-extras using yum
yum -y install amazon-linux-extras
Then install docker using
amazon-linux-extras install docker
I'm on amazon linux (RHEL 7.2) - ami-035b3c7efe6d061d5,
cat /proc/version
Linux version 4.14.123-86.109.amzn1.x86_64 (mockbuild#koji-pdx-corp-builder-64004) (gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)) #1 SMP Mon Jun 10 19:44:53 UTC 2019
Following script works without having to install amazon-linux-extras install
sudo yum -y install docker
sudo service docker start
sudo chmod 666 /var/run/docker.sock
I had to fix permission issue. Also described here How to fix docker: Got permission denied issue
Then I can check containers,
[ec2-user#ip-30-0-0-196 ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
For the Amazon Linux AMI, access to the Extra Packages for Enterprise Linux (EPEL) repository is configured, but it is not enabled by default.
To install amazon-linux-extras, verify connection to the internet from within the instance then check the instance's OS:
cat /etc/os-release
If the OS is amazon linux version 2 run
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Or run sudo yum-config-manager --enable epel
To use the EPEL repository. You can now install available packages... e.g. sudo amazon-linux-extras install docker
see aws documentation for more details.
You can use the below script to install docker inside Amazon Linux 2 Instance. Also, you can mention the below script in the ec2 user data section so at the time of server bootstrap docker will be installed automatically.
#!/bin/bash
sudo yum update -y
sudo yum -y install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo chmod 666 /var/run/docker.sock
Amazon Linux 2 comes with amazon-linux-extras installed. If you think that you are running Amazon Linux 2, and amazon-linux-extras is not on the path of the ec2-user, you might be running an older version of Amazon Linux. Run this command:
grep PRETTY_NAME /etc/os-release
It should output
PRETTY_NAME="Amazon Linux 2"
If you don't see that, go back to the ec2 console and drill-down into the details of the instance. Clicking on the AMI should reveal that it corresponds to an older version of Amazon Linux. Some AWS facilities, notably CDK, currently default to Amazon Linux instead of Amazon Linux 2 when creating new instances.
I came across this question when trying to set up a docker image, based on Amazon Linux 2.
What I didn't find in the current answers is that the docker needs to be enabled in amazon-linux-extras before installing.
Dockerfile commands that worked for me:
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras enable docker
RUN yum install -y docker
I haven't seen any yum packages for php 7.2 on AWS EC2 and the release has been out over a month.
I have tried yum list | grep php7 and only able see php70 and php71 packages.
Has anyone installed php72 on AWS EC2?
Is there another yum repo to connect to?
Does AWS have a delivery scheduled?
Although the #amzn-main repo doesn't have PHP 7.2 yet (as far as I know), you can use remi-php72. According to his release blog you can install the EPEL and Remi repositories via:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm
rpm -Uvh epel-release-latest-6.noarch.rpm
And then enable remi-php72 using yum-config-manager:
yum install yum-utils
yum-config-manager --enable remi-php72
After that, you can simply search and install php and all the needed extensions like normal:
sudo yum install --disablerepo="*" --enablerepo="remi,remi-php72" php php-fpm php-cli ...
As #Typel says in a comment on the other answer - if you're using Amazon Linux 2 AMI then
sudo amazon-linux-extras install -y php7.2
Beats installing multiple external repos and has most of th basics, including mariadb and vim (everything I need to feel happy!).
See the list: sudo amazon-linux-extras list
I have installed docker using sudo yum install -y docker and started the docker service by running the following commands. Initially, it worked and I was able to run docker containers. Now the docker daemon is working but wen I run docker commands like docker ps, docker info..etc. It's not showing anything on stdout.
I have uninstalled the docker version using sudo yum remove docker and removed all the files manually and installed the new one but still it's the same issue.
Here is the link that I have followed to install docker in EC2 instance.
https://aws.amazon.com/blogs/devops/set-up-a-build-pipeline-with-jenkins-and-amazon-ecs/
Docker version
1.12.6, build 7392c3b/1.12.6
uname -a
Linux ip adress 4.4.41-36.55.amzn1.x86_64 #1 SMP Wed Jan 18 01:03:26 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I was not able to figure out what went wrong? Could you please help me in debug this issue.
Thank you in advance.
As I understood from what you said and going through the link you mentioned, you have given the docker command capabilities to the user jenkins, which you have done using :
usermod -a -G docker jenkins
So in order to run docker related command you should login as the user Jenkins. You can use the following command to login as the user jenkins.
sudo -su jenkins
From there you should be able to run the docker commands as expected.
PS - Follow the steps again to install docker.
Hope this help.