Below is a simple example of a Dockerfile to create a Docker container with Debian OS and MySQL installed. This example uses the official MySQL Docker image available on Docker Hub. # Use the official Debian base image FROM debian:latest # Set environment variables for MySQL ENV MYSQL_ROOT_PASSWORD=root_password ENV MYSQL_DATABASE=mydatabase ENV MYSQL_USER=myuser ENV MYSQL_PASSWORD=mypassword # Install MySQL server RUN apt-get update && apt-get install -y \ mysql-server \ && rm -rf /var/lib/apt/lists/* # Configure MySQL to allow remote connections RUN sed -i 's/127.0.0.1/0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf # Expose the MySQL port EXPOSE 3306 # Start MySQL server on container startup CMD ["mysqld"] # To build the Docker image, run: # docker build -t debian-mysql . # To run the container, execute: # docker run -d -p 3306:3306 --name mysql-container debian-mysql Please note that setting a root password for MySQL in this manner is n...
SA Bagus is a blog about computer technology, networking, cloud, crypto, and cyber security.