我们有一个使用MySQL作为DB的Rails应用程序。 db
的{{1}}部分看起来像
docker-compose.yml
并且在 db:
image: mysql
env_file:
- ma.env
volumes:
- ./dump-db:/docker-entrypoint-initdb.d
- ./my.cnf:/etc/mysql/my.cnf
restart: always
ports:
- "3306:3306"
environment:
- MYSQL_HOST=
文件夹下实际上有我们db的sql-dump。
问题是,我们需要在每次./dump-db
运行时加载精确的转储。 MySQL docker镜像以这种方式工作,它将它的数据存储在主机上,因此你的db-service不是无状态的。
我们需要的是,docker-compose up
服务放弃了db
上次运行中完成的所有更改,并使用该确切转储重新启动。
答案 0 :(得分:0)
解决
实际上,上面的想法给了我一些关于RTM的见解,这里就是
/var/lib/mysql
应该安装在主机上。 docker-compose up --force-recreate db
答案 1 :(得分:-1)
如果您不希望每次执行$src1 = imagecreatefromstring( file_get_contents( $_FILES['image']['tmp_name'] ) );
$size1 = getimagesize( $_FILES['image']['tmp_name'] );
$dst1 = imagecreatetruecolor( 696, 400 );
imagecopyresampled( $dst1, $src1, 0, 0, 0, 0, 696, 399, $size1[0], $size1[1] );
imagedestroy( $src1 );
$width = 1200;
$height = 687;
$image = imagecreatetruecolor($width, $height);
imagecopyresampled($image, imagecreatefrompng('images/main.png'),0,0,0,0,$width,$height,$width,$height);
imagecopy($image, $dst1, 333, 103, 0, 0, 696, 399);
$transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagesavealpha($image, true);
imagefill($image, 0, 0, $transparency);
imagedestroy( $dst1 );
imagedestroy( $dst2 );
imagedestroy( $dst3 );
imagedestroy( $dst4 );
ob_start();
imagepng($image, NULL, 0);
$size = ob_get_length();
header("Content-Length: " . $size);
header("Cache-Control: private");
header("Content-Type: image/png");
header("Content-Disposition: attachment; filename=test.png");
时都保留数据,则必须删除执行此命令所创建的卷。
要实现这一点,您可以执行以下命令,该命令将删除docker-compose up
部分中声明的卷的db
服务。
docker-compose down -v db