AWS EC2 instance based on RHEL7.2 ami can not install Docker - amazon-web-services

I created one EC2 instance that's based on AMI: RHEL-7.2_HVM-20161025-x86_64-1-Hourly2-GP2 - ami-2265c543 , but when I wanna install docker via yum install docker -y it shows me error: No package docker available. Error: Nothing to do . So anyone know how to install docker on this ami OS?
thanks in advance.

You can install Docker-CE by setting up Docker repo.
To do So, you can follow official Documentation (Use Docker EE for RHEL).
Install required packages
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
Use the following command to set up the stable repository
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
INSTALL DOCKER CE
sudo yum install docker-ce
Start Docker
sudo systemctl start docker

AWS — RHLE7.5 Free Tier with Docker CE
Since docker is considered an “Extra” rpm with RHLE, then let's explain how you can use Centos Docker Community Edition (CE) for RHLE.
The above step of installing helped me to resolve the problem.
Below I am listing steps to install docker-ce on RHEL.
sudo yum install -y yum-utils
sudo yum-config-manager — add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
To avoid error “Requires: container-selinux >= 2.9”
Run following command
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.42-1.gitad8f0f7.el7.noarch.rpm
To avoid error “libtool-ltdl-2.4.2–22.el7_3.x8 FAILED” Run following command
yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
To avoid Error: Package: docker-ce-18.03.1.ce-1.el7.centos.x86_64 (docker-ce-stable)
Run:
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/pigz-2.3.3-1.el7.centos.x86_64.rpm
sudo yum -y install docker-ce
Can test the docker running with command: sudo systemctl start docker
To check to see if your service is running you can use:
sudo service docker status

Related

CodeBuild with custom docker image get error: Failed to get D-Bus connection: Operation not permitted

I created a docker image:
Dockerfile:
FROM amazonlinux:2 AS core
WORKDIR /root
RUN yum update -y
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash -
RUN yum install -y nodejs
RUN npm install -g less coffeescript
#shodw-utils for use the useradd command.
RUN yum install shadow-utils -y
RUN useradd ec2-user
RUN yum install -y awslogs
RUN yum -y install net-tools
RUN yum install which -y
RUN yum install sudo -y
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install nginx -y
RUN yum clean metadata
RUN yum install -y python3-devel.aarch64
RUN yum install python37
RUN /usr/bin/pip3.7 install virtualenv
RUN virtualenv -p /usr/bin/python3.7 /var/app/.venv
RUN yum install nginx -y
RUN yum -y groupinstall Development tools
RUN yum -y install zlib-devel
RUN yum -y install bzip2-devel openssl-devel ncurses-devel
RUN yum -y install sqlite sqlite-devel xz-devel
RUN yum -y install readline-devel tk-devel gdbm-devel db4-devel
RUN yum -y install libpcap-devel xz-devel
RUN yum -y install libjpeg-devel
RUN yum -y install wget
When i run it with privileged on my local it succeed to run NGINX service with no failure.
CodeBuild (Privileged mode= True) pull this image from ECR but when trying to run NGINX service i got the following error:
Failed to get D-Bus connection: Operation not permitted
any ideas?

can't start minikube in ec2 shows "X Sorry, Kubernetes v1.18.0 requires conntrack to be installed in root's path"

Hi I am trying to start minikube that's why I ran
minikube start --vm-driver=none
But it shows in the console the below lines:
minikube v1.9.2 on Amazon 2 (Xen/amd64)
Using the none driver based on user configuration
X Sorry, Kubernetes v1.18.0 requires conntrack to be installed in root's path
Note that i have installed kubectl minikube and docker.
Please help me to sort out this issues.
I had the same issue. Install 'conntrack' with
sudo apt install conntrack
Then continue to start your minikube:
sudo minikube start --vm-driver=none
Execute following commands
yum install conntrack
start minikube as root
start --driver=none
TL;DR : update minkikube
You need minkikube not older than v1.9.0-beta
It's a known issue
There is a known issue #7179 reproduced in 1.18
Fixed in Pull Request #7180, the latest commit is 1273d4f:
install conntrack for github action integration tests #7180
Minimal minikube ver that contain commit 1273d4f is v1.9.0-beta:
git clone https://github.com/kubernetes/minikube/
cd minikube
git describe 1273d4f8e756ac5eca89d94c449450fb2da21a5a
>v1.9.0-beta.2-16-g1273d4f8e
Explanation of git describe
Explanation of git describe is here
The command is useful for cases such as:
which tag is closest to the commit? (git describe <sha>)
which tag contains commit? (git describe <sha> --contains)
which branch or annotated tag is closest to the commit? (git describe <sha>--all)
On CentOS 7, run following command:
yum install conntrack
And don't forget to have at least 2 (v)CPUs
You need to install conntrack:
apt-get install conntrack -y
and then you can run the minikube start command again
minikube start --vm-driver=none
make sure you do it as a root user or prefix sudo.
If your running ubuntu, make sure you systemd and kubeadm already installed. I found that this resolved for me
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
at <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
Reference Links:
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-
https://minikube.sigs.k8s.io/docs/drivers/none/
I use the following command to resolve the issue:
minikube start --vm-driver=docker

How to install docker on Amazon Linux2

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

How to access the review board site from other system via browser?

I have set-up all prerequisites and all the installation required for local reviewboard along with rb-site, server is apache httpd with mod_wsi. Can any one help me on how to access the review bpoard which I have installed locally from different systems via web browser.
Below are the steps detailed:
yum -y install zlib zlib-devel
yum -y install openssl-devel
yum -y install memcached
yum -y install python-devel
yum -y install python-setuptools
yum -y install patch
easy_install mysql-python
yum -y install git-core
easy_install ReviewBoard
rb-site install /var/www/ReviewBoard
While Installing rb-site :
Domain name localhost:80
Root Path : reviews
And other configurations are default.
All steps are executed successfully.
But I do not know how can I access the review board over browser.
Please help me?

Amazon S3 + Docker - "403 Forbidden: The difference between the request time and the current time is too large"

I am trying to run my django application in a docker container with static files served from Amazon S3. When I run RUN $(which python3.4) /home/docker/code/vitru/manage.py collectstatic --noinput in my Dockerfile, I get a 403 Forbidden error from Amazon S3 with the following response XML
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>RequestTimeTooSkewed</Code>
<Message>The difference between the request time and the current time is too large.</Message>
<RequestTime>Sat, 27 Dec 2014 11:47:05 GMT</RequestTime>
<ServerTime>2014-12-28T08:45:09Z</ServerTime>
<MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>
<RequestId>4189D5DAF2FA6649</RequestId>
<HostId>lBAhbNfeV4C7lHdjLwcTpVVH2snd/BW18hsZEQFkxqfgrmdD5pgAJJbAP6ULArRo</HostId>
</Error>
My docker container is running Ubuntu 14.04... if that makes any difference.
I also am running the application using uWSGI, without nginx or apache or any other kind of reverse-proxy server.
I also get the error at run-time, when the files are being served to the site.
Attempted Solution
Other stackoverflow questions have reported a similar error using S3 (none specifically in conjunction with Docker) and they have said that this error is caused when your system clock is out of sync, and can be fixed by running
sudo service ntp stop
sudo ntpd -gq
sudo service ntp start
so I added the following to my Dockerfile, but it didn't fix the problem.
RUN apt-get install -y ntp
RUN ntpd -gq
RUN service ntp start
I also attempted to sync the time on my local machine before building the docker image, using sudo ntpd -gq, but that did not work either.
Dockerfile
FROM ubuntu:14.04
# Get most recent apt-get
RUN apt-get -y update
# Install python and other tools
RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential
RUN apt-get install -y python3 python3-dev python-distribute
RUN apt-get install -y nginx supervisor
# Get Python3 version of pip
RUN apt-get -y install python3-setuptools
RUN easy_install3 pip
# Update system clock so S3 does not get 403 Error
# NOT WORKING
#RUN apt-get install -y ntp
#RUN ntpd -gq
#RUN service ntp start
RUN pip install uwsgi
RUN apt-get -y install libxml2-dev libxslt1-dev
RUN apt-get install -y python-software-properties uwsgi-plugin-python3
# Install GEOS
RUN apt-get -y install binutils libproj-dev gdal-bin
# Install node.js
RUN apt-get install -y nodejs npm
# Install postgresql dependencies
RUN apt-get update && \
apt-get install -y postgresql libpq-dev && \
rm -rf /var/lib/apt/lists
# Install pylibmc dependencies
RUN apt-get update
RUN apt-get install -y libmemcached-dev zlib1g-dev libssl-dev
ADD . /home/docker/code
# Setup config files
RUN ln -s /home/docker/code/supervisor-app.conf /etc/supervisor/conf.d/
RUN pip install -r /home/docker/code/vitru/requirements.txt
# Create directory for logs
RUN mkdir -p /var/logs
# Set environment as staging
ENV env staging
# Run django commands
# python3.4 is at /usr/bin/python3.4, but which works too
RUN $(which python3.4) /home/docker/code/vitru/manage.py collectstatic --noinput
RUN $(which python3.4) /home/docker/code/vitru/manage.py syncdb --noinput
RUN $(which python3.4) /home/docker/code/vitru/manage.py makemigrations --noinput
RUN $(which python3.4) /home/docker/code/vitru/manage.py migrate --noinput
EXPOSE 8000
CMD ["supervisord", "-c", "/home/docker/code/supervisor-app.conf"]
Noted in the comments but for others who come here:
If using boot2docker (i.e. If on windows or Mac), the boot2docker vm has a known time issue when you sleep your machine--see here. Since the host for your docker container is the boot2docker vm, that's where it syncs its time.
I've had success restarting the boot2docker vm. This may cause problems with losing some state, i.e. If you had some data volumes.
Docker containers share clock with the host machine, so syncing your host machine clock should solve the problem. To force the timezone of your container is the same as your host machine you can add -v /etc/localtime:/etc/localtime:ro in docker run.
Anyway, you should not start a service in a Dockerfile. This file contains the steps and commands to build the image for your containers, and any process you run inside a Dockerfile will end after the building process. To start any service you should add a run script or a process control daemon (as supervisord) which will run each time you run a new container.
Restarting Docker for Mac fixes the error on my machine.