Commit data in a mysql container

前端 未结 4 788
灰色年华
灰色年华 2021-01-11 12:41

I created a mysql container using the officially supported mysql image. I ran the image mounting a folder that contains a sql dump, then I created a new database in the cont

4条回答
  •  忘掉有多难
    2021-01-11 13:19

    Based on the @dekin research, I did this to solve the issue:

    Dockerfile:

    FROM mysql:latest
    
    RUN cp -r /var/lib/mysql /var/lib/mysql-no-volume
    
    CMD ["--datadir", "/var/lib/mysql-no-volume"]
    

    Build & run:

    docker build . -t my-mysql
    docker run -e MYSQL_ROOT_PASSWORD=root -it my-mysql
    

提交回复
热议问题