Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable compose to build Dockerfiles that use --security=insecure. #481

Closed
jvanheesch opened this issue Apr 2, 2024 · 0 comments · Fixed by docker/compose#11708
Closed

Comments

@jvanheesch
Copy link

What is the problem you're trying to solve

I have a multi-stage Dockerfile with multiple RUN --security=insecure docker ... instructions. I want docker compose build to be able to build the corresponding image, just like it can with any regular Dockerfile. I currently run into the following error:

failed to solve: failed to load LLB: security.insecure is not allowed

The Dockerfile currently looks as follows:

# syntax=docker/dockerfile:1-labs
FROM docker as builder
COPY ./run_docker.sh run_docker.sh
RUN --security=insecure ./run_docker.sh 'docker ...'
RUN --security=insecure ./run_docker.sh 'docker ...'
RUN --security=insecure ./run_docker.sh 'docker ...'
FROM openjdk:8-slim
COPY --from=builder /app /app
...

with run_docker.sh:

#!/bin/sh

# Start dockerd in the background
dockerd &
DOCKERD_PID=$!

# Wait until Docker daemon is ready
while ! docker info > /dev/null 2>&1; do
    echo "Waiting for Docker daemon to start..."
    sleep 1
done

sh -c "$@"

# Stop dockerd
kill $DOCKERD_PID
wait $DOCKERD_PID

Unrelated to the issue at hand - this run_docker.sh setup is very awkward, but I wanted separate instructions for each docker command, and could not find a better way to accomplish this. Any feedback on this awkward setup would be greatly appreciated.

I could build a similar image using docker commit, but I don't think this way of building images can be integrated with docker (compose) build. As such, this Dockerfile basically starts a container with a volume, does some stuff, and copies the volume to a new image.

Describe the solution you'd like
Based on #120, I think supporting --allow security.insecure would be appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant