klo2k
Posted on February 28, 2023
Using -
as docker build
parameter, you can pipe in any text as your Dockerfile.
I use this trick to quickly test parts of a Dockerfile.
e.g.:
# Build the image, with '-' + heredoc as input
# Works the same with pipe input
docker build --tag klo2k/test - <<'EOT'
FROM ubuntu:latest
# Some complicated looking stuff you wanna try out quickly
RUN <<'EOS' /bin/bash
echo "${HOSTNAME}" > /tmp/out
EOS
CMD echo "Build: $(cat /tmp/out) Run: ${HOSTNAME}"
EOT
# Run
docker run --rm -it klo2k/test
Example Output:
Build: buildkitsandbox Run: a16cd7dc16ed
Hope you find this useful!
💖 💪 🙅 🚩
klo2k
Posted on February 28, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.