Home:ALL Converter>Create a Dockerfile with ubuntu image and run mysql in it

Create a Dockerfile with ubuntu image and run mysql in it

Ask Time:2022-11-07T00:08:24         Author:lazlomeli

Json Formatter

I am trying to set up a Dockerfile with an ubuntu image that runs a mysql server (I know I should use the mysql image instead, but I need to do it this way for an assignment). I am having a lot of trouble designing the Dockerfile. My Dockerfile looks like this right now:

FROM ubuntu:latest

EXPOSE 3306

VOLUME [ "/var/lib/mysql" ]

RUN apt update && \
    apt install -y mysql-server && \
    apt-get install -y gosu

ENV MYSQL_ROOT_PASSWORD=secret

COPY ./wordpress.sql /docker-entrypoint-initdb.d/

COPY ./docker-entrypoint.sh /usr/local/bin/

COPY ./entrypoint.sh /

RUN chmod +x entrypoint.sh && \
    chmod +x /docker-entrypoint-initdb.d/wordpress.sql && \
    chmod +x /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "mysqld" ]

(I am running docker build -t sql . to build the image, and docker run --name sql_cont -v sql_vol:/var/lib/mysql sql_img to run the container)

I have a folder where I have the docker-entrypoint.sh file and the entrypoint.sh file, because when I install mysql-server, these files are not created by default as If I was just using the mysql docker image.

I just need a Dockerfile from an ubuntu image that runs mysql and just stays waiting ready for connections, so, If anybody know how to refactor this Dockerfile or just give me the answer I'd much appreciate it.

Author:lazlomeli,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74337548/create-a-dockerfile-with-ubuntu-image-and-run-mysql-in-it
yy