Advertisement
DigitalMag

docker mysql

Nov 12th, 2020
1,417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. FROM ubuntu
  2. LABEL maintainer="author@mail.ru"
  3. ENV ADMIN="admin"
  4.  
  5. RUN apt update && apt install mysql-server mysql-client -y
  6. RUN cp -r -p /var/lib/mysql /var/init_data
  7.  
  8. COPY ./app ./app
  9.  
  10. CMD /app/startup.sh
  11. CMD service mysql start
  12.  
  13. WORKDIR /home
  14.  
  15.  
  16.  
  17. startup.sh:
  18.  
  19. #!/bin/bash
  20. if [ ! -f /var/lib/mysql/ibdata1 ]; then
  21.     echo "data initialize..."
  22.     cp -r -p /var/init_data/* /var/lib/mysql
  23. else
  24.     echo "data has restored from volume"
  25. fi
  26.  
  27.  
  28.  
  29. # run:
  30. docker run -it --name mysql -p 3306:3306 -v /home/docker/mysql:/var/lib/mysql mysql bash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement