I want to configure a container with MySQL, thereafter I will add a java application to the container. But, I could not install MySQL-server inside the container.
here is my dockerfile:
FROM ubuntu:latest
RUN apt-get -y update
RUN apt-get -y install mysql-server --fix-missing --fix-broken
EXPOSE 3306
CMD ["/usr/bin/mysqld_safe"]
I got the following error:
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.5_5.5.44-0ubuntu0.14.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
2015/09/01 13:17:36 The command [/bin/sh -c apt-get -y install mysql-server --fix-missing --fix-broken] returned a non-zero code: 100
What's probably happening is the apt-get install is asking for input, and failing. What happens if you just run those commands interactively in the base container? e.g. launch a shell with docker run -ti --rm ubuntu:latest /bin/bash
One thing you can try is to use the DEBIAN_FRONTEND=noninteractive environment variable, e.g.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install mysql-server
I would suggest you use the official mysql docker image. When running that you have to provide the root password as an environment variable during the docker run command. That would be better.
Related
When I run docker-compose up to install our MySQL server, I get the following error:
RUN apt-get -y update && apt-get upgrade -y:
/bin/sh: apt-get: command not found
from the relevant dockerfile code:
FROM mysql:5.7
RUN apt-get -y update && apt-get upgrade -y
This used to work fine a few months ago for my coworkers.
Apparently since Oracle bought MySQL in 2010, they have been converting everything over to their proprietary OS. In the last few months, they switched the default mysql package to Oracle OS from Debian.
See the packages here: https://hub.docker.com/_/mysql
You now need to specify the debian package like:
FROM mysql:5.7-debian
RUN apt-get -y update && apt-get upgrade -y
I'm updating apt and installing mysql-client at run time to a ubuntu 18.04 aws instance.
My shell command are like,
- apt-get update
- apt-get install -y mysql-client
- apt-get install -y unzip
But 'apt-get install -y mysql-client' hang and lock apt. Therefor 'apt-get install -y unzip' get fail. So to proceed this, I have to manually kill the process and unclock the apt from following commands.
Step 01. ps -ef | grep apt
Step 02. kill -9
Step 03. sudo dpkg --configure -a
Step 04. Yes the below message
restarts will be done for you automatically so you can avoid being asked questions on each library upgrade. │ Restart services during package upgrades without asking?
Step 05. apt-get install -y mysql-client
My question is how I implement following from shell script or is there a any way to install mysql-client at run time?
Try to set DEBIAN_FRONTEND=noninteractive and the -q parameter to avoid apt from opening interactive prompts.
e.g:
DEBIAN_FRONTEND=noninteractive apt-get install -yq mysql-client
I'm trying to create a galera docker image based on this dockerfile file from this link
http://galeracluster.com/documentation-webpages/docker.html
FROM ubuntu:14.04
MAINTAINER your name <your.user#example.org>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv BC19DDBA
RUN add-apt-repository 'deb http://releases.galeracluster.com/ubuntu trusty main'
RUN apt-get update
RUN apt-get install -y galera-3 galera-arbitrator-3 mysql-wsrep-5.6 rsync
COPY my.cnf /etc/mysql/my.cnf
ENTRYPOINT ["mysqld"]
But I get this error
W: Failed to fetch http://releases.galeracluster.com/ubuntu/dists/trusty/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Can you please help me !! It used to work fine for me two weeks ago !! any idea ??
I have a mysql container created using docker file
from ubuntu:14.04
run apt-get update && apt-get install -y apt-transport-https
run apt-get install mysql-server -y
run apt-get install mysql-client -y
RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN apt-get install oracle-java7-installer -y && \ oracle-java7-set-default
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
env set MYSQL_ROOT_PASSWORD=root
EXPOSE 3306
and an java container from java:8 image. The java container is linked to mysql container using --link option.
docker run -it --link mysqlc:csql java:8
Now i need to execute mysql commands from java container but mysql commands not working in java container. What is the problem?
I need to start mysql, create databases from java container? How to do this?
Do i need to use another image other than java to access mysql container?
An approach is building your own Java image that contains mysql-client as long as Java:
Dockerfile:
FROM Java:8
RUN apt-get update && apt-get install mysql-client
Build:
docker build . -t my-java-mysql
Run:
docker run -it --link mysqlc:csql my-java-mysql:8
Then you have mysql client command available in your Java container.
I can't for the life of me figure this out. I feel like I'm really close, but im just not quite there yet. Here's my Dockerfile:
FROM ubuntu:14.04
MAINTAINER Oscar Godson
RUN apt-get update
RUN apt-get install -y nodejs-legacy
RUN apt-get install -y npm
RUN apt-get install -y mysql-server
RUN apt-get install -y mysql-client
COPY . /src
WORKDIR /src
RUN service mysql start;\
mysql -u root < /src/bin/demo-data.sql;\
npm install
EXPOSE 4000
CMD ["node", "index.js"]
If i go into interactive mode and go into bash in that RUN service... line at the end I can see that mysql is running, the demo data was imported and everything works including starting my Node app with node index.js. If I then try to do another RUN or the CMD you see below it no longer can access MySQL. It's like it stops running.
The error I get Error: connect ECONNREFUSED which happens when it's down or the data isn't there. From me playing with it it looks like MySQL isn't running if I try to access it after the RUN where I start it.
P.S. The MySQL DB here is purely for development. On production we use AWS RDS, so thats why its using root without any password and importing data that way.
The problem was that RUN shouldn't be used for long running processes, however, you can only use one CMD option. For some reason it didn't click with me until a friend pointed it out, but I could just make a "installer.sh" script and call that with CMD. Now it's not losing the MySQL context. My update Dockerfile looks something like this:
FROM ubuntu:14.04
MAINTAINER Oscar Godson
RUN apt-get update
RUN apt-get install -y nodejs-legacy
RUN apt-get install -y npm
RUN apt-get install -y mysql-server
RUN apt-get install -y mysql-client
COPY . /src
WORKDIR /src
RUN cd /src;npm install
EXPOSE 4000
CMD ./bin/installer.sh
Installer than has
service mysql start
mysql -u root < ./bin/demo-data.sql
node index.js