I was trying to create a Docker Image for ProxySQL . Following is my DockerFile
FROM rhel7:latest
USER root
MAINTAINER Ques Zama
# Update the image with the latest packages (recommended)
RUN yum update -y; yum clean all
# Update image
RUN yum-config-manager --enable proxysql_repo
# Install ProxySQL
RUN yum install proxysql -y
# Expose ProxySQL Port 6034
EXPOSE 6034
# Start the service
CMD /etc/init.d/service start proxysql
I was trying to build the image with below command
sudo docker build --no-cache -t zama_proxysql .
But I can it is not able to install the proxysql package using yum command as mentioned in Dockerfile . Following is the message below
Step 6 : RUN yum install proxysql -y
---> Running in 54cc1ae88ba3
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
No package proxysql available.
Error: Nothing to do
The command '/bin/sh -c yum install proxysql -y' returned a non-zero code: 1
If I execute the command yum install proxysql in commandline , it works fine . But from Dockerfile , it could not find the package. Please note that I have already enabled the repo for proxysql in /etc/yum.repos.d
Any suggestions to resolve the issue
Try adding the repo manually first instead of using yum-config-manager :
cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL YUM repository
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasever
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
This works properly on a FROM centos:7 image.
Related
My Dockerfile
FROM centos:7
# Install Apache
RUN yum -y update
RUN yum -y install httpd httpd-tools
# Install EPEL Repo
RUN yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Install PHP
RUN yum install yum-utils
RUN yum-config-manager --enable remi-php73
RUN yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
# Update Apache Configuration
RUN sed -E -i -e '/<Directory "\/var\/www\/html">/,/<\/Directory>/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -E -i -e 's/DirectoryIndex (.*)$/DirectoryIndex index.php \1/g' /etc/httpd/conf/httpd.conf
EXPOSE 80
# Start Apache
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
When I want to build this image I get
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm]: runc did not terminate successfully
How can build a docker image with centos apache and PHP 73?
remove the three lines
# Install EPEL Repo
RUN yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
those commands don't exist, I suspect you tried to copy instruction for dnf and replaced dnf with yum, that won't work.
And anyways you don't need those.
If you do need them, you can try
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
or maybe
RUN yum -y update; \
yum install -y epel-release; \
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
I am trying to dockerfy the installation guide described here:
https://docs.opsmanager.mongodb.com/current/tutorial/install-simple-test-deployment/
I have created this minimal dockerfile:
FROM registry.access.redhat.com/rhel7/rhel:latest
RUN yum install -y mongodb-org mongodb-org-shell
But when I build it I get:
$ docker build . -t my-image
Sending build context to Docker daemon 22.53kB
Step 1/2 : FROM x.y.z:1234/rhel7/rhel:latest
---> 6979ec30598b
Step 2/2 : RUN yum install -y mongodb-org mongodb-org-shell
---> Running in d696383b761d
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
From the above guide I need to first add:
echo "[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" | sudo tee /etc/yum.repos.d/mongodb.repo
this to my dockerfile. Any input/examples on how to do that? I guess I basically need to copy the above text block into a /etc/yum.repos.d/mongodb.repo file on the image?
Edit: Based on below answer I can now docker ADD the repo file into the image and the above error is fixed. But I get this instead:
--> Processing Dependency: openssl for package: mongodb-org-tools-4.0.9-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: mongodb-org-tools-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
Error: Package: mongodb-org-server-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
Error: Package: mongodb-org-shell-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
The command '/bin/sh -c yum install -y mongodb-org mongodb-org-shell' returned a non-zero code: 1
Not sure if that is related to the repo information. I also tried to install openssl in dockerfile with:
RUN yum install openssl
but that gives:
No package openssl available.
Error: Nothing to do
The command '/bin/sh -c yum install openssl' returned a non-zero code: 1
Create a file in the same folder of your Dockerfile with the contents and add them to the image. Example:
cat <<EOF > mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF
Then in your Dockerfile:
FROM registry.access.redhat.com/rhel7/rhel:latest
ADD mongodb.repo /etc/yum.repos.d/mongodb.repo
RUN yum update && \
yum install -y mongodb-org mongodb-org-shell
I have created a ssh key using ssh-keygen and added id-rsa.pub content to my github>settings>SSH & GPG keys.
I am able to clone the repo from my terminal with git clone git#github:myname/myrepo.git
But the same is giving the following error while building the docker file.
Cloning into 'Project-Jenkins'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
This is how I added the command in dockerfile
RUN git clone git#github.com:myname/myrepo.git
What went wrong here?
here is my dockerfile
FROM ubuntu
COPY script.sh /script.sh
CMD ["/script.sh"]
FROM python:2.7
RUN apt-get update
RUN apt-get install libmysqlclient-dev
RUN apt-get install -y cssmin
RUN apt-get install -y python-psycopg2
RUN pip install --upgrade setuptools
RUN pip install ez_setup
RUN apt install -y libpq-dev python-dev
RUN apt install -y postgresql-server-dev-all
COPY requirements.txt ./
CMD ["apt-get","install","pip"]
RUN apt-get install -y git
RUN git clone git#github.com:myname/myrepo.git
WORKDIR ./myrepo/LIMA
RUN pip install -r requirements.txt
CMD ["python","manage.py","migrate"]
CMD ["python","manage.py","collectstatic","--noinput"]
CMD ["python","manage.py","runserver"]
EXPOSE 8000
The syntax you have used finally ends up using SSH to clone, and inside the docker container, your github private key is not available which leads to error that you are getting. So instead try using,
RUN git clone https://{myusername}:{mypassword}#github.com/{myusername}/myrepo.git
Also remember if your password has '#' symbol use '%40' instead.
If you want to still go with private key approach, refer this question, How to access GIT repo with my private key from Dockerfile
When I am running the build command:
$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM
Unknown instruction: FROM
dev#ub:~/cowsay$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM ubuntu:14.04
---> 90d5884b1ee0
Step 2 : RUN apt-get -y install cowsay
---> Running in 587aaba2824b
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package cowsay
The command '/bin/sh -c apt-get -y install cowsay' returned a non-zero code: 100
Content of Dockerfile is as follow:
FROM ubuntu:14.04
RUN apt-get -y install cowsay
RUN apt-get -y install fortune
ENTRYPOINT ["/usr/games/cowsay"]
CMD ["Docker is so awesomoooooooo!"]
ONBUILD RUN /usr/games/fortune | /usr/games/cowsay
How can I avoid this error message?
Try and add RUN apt-get update first.
Once the packages are updated, you can install, for instance, cowsay.
See for instance this Dockerfile as an example of RUN apt-get commands:
FROM debian:jessie
RUN apt-get update && apt-get install -y cowsay
COPY docker.cow /usr/share/cowsay/cows/docker.cow
ENTRYPOINT ["/usr/games/cowsay","-f","docker"]
CMD ["moby","dock"]
I'm trying to create a VM with docker and boot2docker. I've made the following Dockerfile, which I'm trying to run through the command line
docker run Dockerfile
Immidiatly it says exactly this:
Unable to find image 'Dockerfile:latest' locally
FATA[0000] Invalid repository name <Dockerfile>, only [a-z0-9_.] are allowed
Dockerfile:
FROM ubuntu:latest
#Oracle Java7 install
RUN apt-get install software-properties-common -y
RUN apt-get update
RUN add-apt-repository -y ppa:webupd8team/java
RUN apt-get update
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java7-installer
#Jenkins install
RUN wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
RUN sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install --force-yes -y jenkins
RUN sudo service jenkins start
#Zip support install
RUN apt-get update
RUN apt-get -y install zip
#Unzip hang.zip
RUN unzip -o /var/jenkins/hang.zip -d /var/lib/jenkins/
RUN chown -R jenkins:jenkins /vaR/lib/jenkins
RUN service jenkins restart
EXEC tail -f /etc/passwd
EXPOSE 8080
I am in the directory where the Dockerfile is, when trying to run this command.
Ignore the zip part, as that's for later use
You should run docker build first (which actually uses your Dockerfile):
docker build --tag=imagename .
Or
docker build --tag=imagename -f yourDockerfile .
Then you would use that image tag to docker run it:
docker run imagename
There are tools that can provide this type of feature.
We have achieved using docker compose, though you have to go through
(https://docs.docker.com/compose/overview/)
docker-compose up
but you can also do as work around
$ docker build -t foo . && docker run foo.