`DockerResponseServerError { status_code: 400, message: "file with no instructions" }`
fmckeogh opened this issue · comments
The following function for creating a WASM image in the local registry works in bollard 0.14.0
but fails with DockerResponseServerError { status_code: 400, message: "file with no instructions" }
in bollard 0.15.0
.
I have bisected the commits, and it appears that it was merge request #335 that caused the issue, but I can't find out how sending an empty changes
field causes the error.
/// Creates an image in the local registry from the provided WASM module bytes
pub async fn create_image_from_slice(
image_name: &str,
tag: &str,
module: &[u8],
) -> eyre::Result<()> {
let options = CreateImageOptions {
from_src: "-", // from_src must be "-" when sending the archive in the request body
repo: image_name, // The name of the image in the docker daemon.
tag, // The tag of this particular image.
..Default::default()
};
// Create a Body from the byte slice
let req_body = hyper::body::Body::from({
let mut buffer = Vec::new();
{
let mut builder = tar::Builder::new(&mut buffer);
let mut header = tar::Header::new_gnu();
header.set_path("entrypoint.wasm")?;
header.set_size(module.len() as u64);
header.set_cksum();
builder.append_data(&mut header, "entrypoint.wasm", module)?;
builder.finish()?;
}
buffer
});
// Call Docker::create_image with the options and the body
Docker::connect_with_local_defaults()?
.create_image(Some(options), Some(req_body), None)
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<Result<Vec<_>, bollard::errors::Error>>()
.unwrap();
Ok(())
}
Thanks for this, I don't think we have this use case covered in our tests.. I've only recently read that this is possible.
@fussybeaver Any recommendations on how I could debug/fix this?:)
I would setup an env_logger
at the start of your script and run with RUST_LOG=bollard=debug
to check what the request envelope looks like. You can try and compare it with a simple curl request on the docker socket to check if that's working.
@fussybeaver Diffing the logs showed the only change was the extra &changes=
parameter in the request. I think the Docker error is suggesting that if the Vec
is empty the parameter shouldn't be passed? I can open a PR if that fix is acceptable to you.