Skip to content

Instantly share code, notes, and snippets.

@jedvardsson
Last active February 24, 2022 15:06
Show Gist options
  • Save jedvardsson/df4d88a06074900f1eb3b2cb41d00c3a to your computer and use it in GitHub Desktop.
Save jedvardsson/df4d88a06074900f1eb3b2cb41d00c3a to your computer and use it in GitHub Desktop.
Test to reproduce buildkit network mode not supported https://github.com/moby/buildkit/issues/978
#!/usr/bin/env bash
set -o errexit
set -o pipefail
function finally() {
docker stop -t 1 my-nginx || true
}
trap finally EXIT
function log_info() {
echo -e "\\e[1;34m[INFO]\\e[0m" "$@"
}
log_info "starting my-nginx"
docker run --rm --name my-nginx -d nginx
log_info "build --network=container:my-nginx..."
docker build --network=container:my-nginx - <<EOF
FROM alpine
RUN apk add --no-cache curl
RUN curl -sS http://localhost:80 > /dev/null
EOF
log_info "It works!"
@jedvardsson
Copy link
Author

jedvardsson commented Feb 24, 2022

Script to reproduce Error response from daemon: network mode "container:my-nginx" not supported by buildkit

moby/buildkit#978

$ DOCKER_BUILDKIT=1 ./test.sh
[INFO] starting my-nginx
33b5ed53eba7f80f8be12615b3f617003889c673aecb0acc916f661b8654447d
[INFO] build --network=container:my-nginx...
Error response from daemon: network mode "container:my-nginx" not supported by buildkit
my-nginx
$ DOCKER_BUILDKIT=0 ./test.sh
[INFO] starting my-nginx
41010888b556e1a4acbc397c9e44e153e0bb5cb291a91968d2e63d21d8dd7215
[INFO] build --network=container:my-nginx...
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM alpine
 ---> 8e1d7573f448
Step 2/3 : RUN apk add --no-cache curl
 ---> Using cache
 ---> 6e141d1b9de5
Step 3/3 : RUN curl -sS http://localhost:80 > /dev/null
 ---> Using cache
 ---> b7fcaaa6dd4e
Successfully built b7fcaaa6dd4e

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
[INFO] It works!
my-nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment