![]() # mysqldump -u root -p my_db_name > data.sqlĪt a high level, the backup file will drop any table named Customers in the chosen database and insert all backed-up data into it: # cat data.sql Using a simple command with inline arguments, we can quickly take the backup of the MySQL tables: | Wilman Kala | Matti Karttunen | Keskuskatu 45 | Helsinki | 21240 | Finland |Īs part of the MySQL RDBMS package, the mysqldump utility is used to backup all data in a database into a text file. Erichsen | Skagen 21 | Stavanger | 4006 | Norway | | CustomerName | ContactName | Address | City | PostalCode | Country | EXPOSE – Make the services available outside the Docker Container.īelow, we’ve showcased the table data using the SELECT query, which fetches data from the requested table: mysql> select * from Customers.ADD – During build time, it will add the file into the container for future use.In the above snippet, we use four variables. ENV – We use the $ symbol to represent the environment variables in Dockerfile.Here, we are passing four user variables as build arguments. ARG – Pass variables during build time.The resultant- image is committed and used for the next steps defined in the Dockerfile. RUN – Execute the command on top of the mysql image, which subsequently forms a new layer.MAINTAINER – Set the author information as the container’s metadata that is visible through the docker inspect.In our case, we use the mysql image with the latest tag. FROM – A valid Dockerfile begins with the FROM statement, which describes the image name and version tag. ![]() Now, let’s have a glimpse of all the instructions given in the below Dockerfile snippet: RUN cp /etc/mysql/data.sql /docker-entrypoint-initdb.d RUN sed -i 's/MYSQL_DATABASE/'$MYSQL_DATABASE'/g' /etc/mysql/data.sql Our Dockerfile downloads the image from DockerHub and spins up the container with the defined variables: # cat DockerfileĮNV MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD Internally, docker-compose uses the Dockerfile in the specified path to build the image and set the environment for MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |